using AutoMapper; using Microsoft.EntityFrameworkCore; using SytelineSaAppEfDataModel.Dtos; namespace SytelineSaAppEfDataModel.Services; public class MaterialTransactionService(SytelineSaAppDbContext context, IMapper mapper) : IMaterialTransactionService { public async Task> GetAll() { return await context.MaterialTransactions.Select(x => mapper.Map(x)).ToListAsync(); } public async Task GetByWzNumber(string wzNumber) { return await context.MaterialTransactions .Where(x => x.MTGroupNum == wzNumber) .Select(x => mapper.Map(x)).FirstOrDefaultAsync(); } public async Task> GetByWzNumbers(ISet wzNumbers) { return await context.MaterialTransactions .Where(x => !string.IsNullOrWhiteSpace(x.MTGroupNum) && wzNumbers.Contains(x.MTGroupNum)) .Select(x => mapper.Map(x)).ToListAsync(); } public async Task> GetByOrderNumber(string orderNumber) { return await context.MaterialTransactions.Where(x => x.RefNum == orderNumber) .Select(x => mapper.Map(x)).ToListAsync(); } }