25 lines
991 B
C#
25 lines
991 B
C#
using AutoMapper;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using SytelineSaAppEfDataModel.Dtos;
|
|
|
|
namespace SytelineSaAppEfDataModel.Services
|
|
{
|
|
public class ErrorLogService(SytelineSaAppDbContext context, IMapper mapper) : IErrorLogService
|
|
{
|
|
public async Task<IEnumerable<ErrorLogDto>> GetAll()
|
|
{
|
|
return await context.ErrorLogs.Select(x => mapper.Map<ErrorLogDto>(x)).ToListAsync();
|
|
}
|
|
|
|
public async Task<IEnumerable<ErrorLogDto>> GetByOrderNumber(Guid customerOrderNumber)
|
|
{
|
|
EdiCustomerOrderDto ediCustomerOrderDto = mapper.Map<EdiCustomerOrderDto>(
|
|
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<ErrorLogDto>(x)).ToListAsync();
|
|
}
|
|
}
|
|
} |