* Changed behaviour of scanning to scan first PartNumber, select specific record and then scan MeylePartNumber
25 lines
816 B
C#
25 lines
816 B
C#
using AutoMapper;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using SytelineSaAppEfDataModel.Dtos;
|
|
|
|
namespace SytelineSaAppEfDataModel.Services;
|
|
|
|
public class LotService(SytelineSaAppDbContext context, IMapper mapper) : ILotService
|
|
{
|
|
public async Task<IEnumerable<LotDto>> GetAll()
|
|
{
|
|
return await context.Lots.Select(x => mapper.Map<LotDto>(x)).ToListAsync();
|
|
}
|
|
|
|
public async Task<LotDto?> GetByItemNumber(string itemNumber)
|
|
{
|
|
return await context.Lots.Where(x => x.Item == itemNumber).Select(x => mapper.Map<LotDto>(x))
|
|
.FirstOrDefaultAsync();
|
|
}
|
|
|
|
public async Task<LotDto?> GetByLotNumber(string lotNumber)
|
|
{
|
|
return await context.Lots.Where(x => x.LotNumber == lotNumber).Select(x => mapper.Map<LotDto>(x))
|
|
.FirstOrDefaultAsync();
|
|
}
|
|
} |