Files
FA_WEB/SytelineSaAppEfDataModel/Services/ErrorLogService.cs
Piotr Kus 51f5c09d82 * Removed not needed code
* Changed string parameters to GUID
2025-02-01 07:21:57 +01:00

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