* Introduced new WzRowMareli service to handle new client

This commit is contained in:
2025-09-08 21:19:17 +02:00
parent f45baa31a5
commit 89792d3d28
8 changed files with 201 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
using SytelineSaAppEfDataModel.Dtos;
namespace SytelineSaAppEfDataModel.Services;
public interface IWzRowMareliService
{
Task<IEnumerable<WzRowMareliDto>> GetAll();
Task CreateRows(IEnumerable<WzRowMareliDto> rows);
Task<IEnumerable<WzRowMareliDto>> GetByWzHeaderId(Guid wzHeaderId);
Task UpdateRows(IEnumerable<WzRowMareliDto> rows);
}

View File

@@ -0,0 +1,36 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using SytelineSaAppEfDataModel.Dtos;
using SytelineSaAppEfDataModel.Entities;
namespace SytelineSaAppEfDataModel.Services;
public class WzRowMareliService(SytelineSaAppDbContext context, IMapper mapper) : IWzRowMareliService
{
public async Task<IEnumerable<WzRowMareliDto>> GetAll()
{
return await context.WzRowsMeyle.Select(x => mapper.Map<WzRowMareliDto>(x)).ToListAsync();
}
public async Task CreateRows(IEnumerable<WzRowMareliDto> rows)
{
var entities = mapper.Map<IEnumerable<WzRowMareli>>(rows);
await context.WzRowsMareli.AddRangeAsync(entities);
await context.SaveChangesAsync();
}
public async Task<IEnumerable<WzRowMareliDto>> GetByWzHeaderId(Guid wzHeaderId)
{
return await context.WzRowsMareli
.Where(x => x.FKHeader == wzHeaderId)
.Select(x => mapper.Map<WzRowMareliDto>(x))
.ToListAsync();
}
public async Task UpdateRows(IEnumerable<WzRowMareliDto> rows)
{
var entities = mapper.Map<IEnumerable<WzRowMareli>>(rows);
context.WzRowsMareli.UpdateRange(entities);
await context.SaveChangesAsync();
}
}