using AutoMapper; using Microsoft.EntityFrameworkCore; using SytelineSaAppEfDataModel.Dtos; using SytelineSaAppEfDataModel.Entities; namespace SytelineSaAppEfDataModel.Services; public class WzRowMeyleService(SytelineSaAppDbContext context, IMapper mapper) : IWzRowMeyleService { public async Task> GetAll() { return await context.WzRowsMeyle.Select(x => mapper.Map(x)).ToListAsync(); } public async Task CreateRows(IEnumerable rows) { var entities = mapper.Map>(rows); await context.WzRowsMeyle.AddRangeAsync(entities); await context.SaveChangesAsync(); } public async Task> GetByWzHeaderId(Guid wzHeaderId) { return await context.WzRowsMeyle .Where(x => x.FK_Header == wzHeaderId) .Select(x => mapper.Map(x)) .ToListAsync(); } public async Task UpdateRows(IEnumerable rows) { var entities = mapper.Map>(rows); context.WzRowsMeyle.UpdateRange(entities); await context.SaveChangesAsync(); } }