* Added MaterialTransaction entity, dto and service

This commit is contained in:
2025-04-01 20:49:31 +02:00
parent 0eaf941021
commit 3f0da4ba79
6 changed files with 299 additions and 5 deletions

View File

@@ -0,0 +1,26 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using SytelineSaAppEfDataModel.Dtos;
namespace SytelineSaAppEfDataModel.Services;
public class MaterialTransactionService(SytelineSaAppDbContext context, IMapper mapper) : IMaterialTransactionService
{
public async Task<IEnumerable<MaterialTransactionDto>> GetAll()
{
return await context.MaterialTransactions.Select(x => mapper.Map<MaterialTransactionDto>(x)).ToListAsync();
}
public async Task<MaterialTransactionDto?> GetByWzNumber(string wzNumber)
{
return await context.MaterialTransactions
.Where(x => x.MTGroupNum == wzNumber)
.Select(x => mapper.Map<MaterialTransactionDto>(x)).FirstOrDefaultAsync();
}
public async Task<IEnumerable<MaterialTransactionDto?>> GetByOrderNumber(string orderNumber)
{
return await context.MaterialTransactions.Where(x => x.RefNum == orderNumber)
.Select(x => mapper.Map<MaterialTransactionDto>(x)).ToListAsync();
}
}