using AutoMapper; using Microsoft.EntityFrameworkCore; using SytelineSaAppEfDataModel.Dtos; namespace SytelineSaAppEfDataModel.Services { public class ErrorLogService(SytelineSaAppDbContext context, IMapper mapper) : IErrorLogService { public async Task> GetAll() { return await context.ErrorLogs.Select(x => mapper.Map(x)).ToListAsync(); } public async Task> GetByOrderNumber(Guid customerOrderNumber) { EdiCustomerOrderDto ediCustomerOrderDto = mapper.Map( await context.EdiCustomerOrders.FirstOrDefaultAsync(x => x.RowPointer.Equals(customerOrderNumber))); if (ediCustomerOrderDto == null) return []; return await context.ErrorLogs.Where(x => x.TrxNum == ediCustomerOrderDto.CustomerOrderNumber) .Select(x => mapper.Map(x)).ToListAsync(); } } }