using DaSaSo.Domain.Model; using DaSaSo.Domain.Services; using DaSaSo.EntityFramework.Services.Common; using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DaSaSo.EntityFramework.Services { public class ImpregnationDataService : IDataService { private readonly DaSaSoDbContextFactory _contextFactory; private readonly NonQueryDataService _nonQueryDataService; public ImpregnationDataService(DaSaSoDbContextFactory contextFactory) { _contextFactory = contextFactory; _nonQueryDataService = new NonQueryDataService(contextFactory); } public async Task Create(Impregnation entity) { return await _nonQueryDataService.Create(entity); } public Impregnation CreateNonAsync(Impregnation entity) { throw new NotImplementedException(); } public async Task Delete(int id) { return await _nonQueryDataService.Delete(id); } public Task Get(int id) { throw new NotImplementedException(); } public async Task> GetAll() { using DaSaSoDbContext context = _contextFactory.CreateDbContext(); IEnumerable entities = await context.Impregnations.ToListAsync(); return entities; } public Task Update(int id, Impregnation entity) { return _nonQueryDataService.Update(id, entity); } } }