* Introduced new WzRowMareli service to handle new client
This commit is contained in:
36
SytelineSaAppEfDataModel/Services/WzRowMareliService.cs
Normal file
36
SytelineSaAppEfDataModel/Services/WzRowMareliService.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user