using Microsoft.Extensions.Options; using MySqlConnector; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AutoService.Models { public class ServiceRepository : BaseRepository, IServiceRepository { public ServiceRepository(IOptions databaseSettings) : base(databaseSettings) { } public IEnumerable GetAll() { string sql = "SELECT * FROM services"; List result = new(); try { OpenConnection(); using var mc = new MySqlCommand(sql, connection); using var reader = mc.ExecuteReader(); while (reader.Read()) { result.Add(new Service() { Id = reader.GetInt32("id"), Title = reader.GetString("title"), Description = reader.GetString("description") }); } CloseConnection(); } catch (Exception e) { Console.WriteLine(e); } return result; } } }