Files
FA_WEB/SytelineSaAppEfDataModel/Services/MaterialTransactionService.cs

26 lines
1009 B
C#

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();
}
}