* Further improvements of Warehouse view
* Fixed issue with not saving Products updates
This commit is contained in:
@@ -5,12 +5,9 @@ using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FaKrosnoEfDataModel.Services;
|
||||
|
||||
public class ProductService : ServiceBase<ProductDto>, IProductService
|
||||
public class ProductService(FaKrosnoDbContext context, IMapper mapper)
|
||||
: ServiceBase<ProductDto>(context, mapper), IProductService
|
||||
{
|
||||
public ProductService(FaKrosnoDbContext context, IMapper mapper) : base(context, mapper)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ProductDto?>> GetEntities()
|
||||
{
|
||||
IList<ProductDto> products = (await GetAll()).ToList();
|
||||
@@ -22,9 +19,10 @@ public class ProductService : ServiceBase<ProductDto>, IProductService
|
||||
{
|
||||
IList<RecipientDto> recipients =
|
||||
(await Context.Recipients.ToListAsync()).Select(x => Mapper.Map<RecipientDto>(x)).ToList();
|
||||
IList<PurchaserDto> purchasers = (await Context.Purchasers.ToListAsync()).Select(x => Mapper.Map<PurchaserDto>(x)).ToList();
|
||||
IList<ProductDto> products = (await GetAll()).ToList();
|
||||
|
||||
IEnumerable<ProductDto> productDtos = products.Where(x => x?.FaIdx == indexName);
|
||||
IEnumerable<ProductDto> productDtos = products.Where(x => x.FaIdx == indexName).ToList();
|
||||
|
||||
foreach (ProductDto productDto in productDtos)
|
||||
{
|
||||
@@ -35,6 +33,13 @@ public class ProductService : ServiceBase<ProductDto>, IProductService
|
||||
productDto.Recipient = recipient;
|
||||
productDto.RecipientName = recipient.RecipientDesc;
|
||||
}
|
||||
|
||||
PurchaserDto? purchaser = purchasers.FirstOrDefault(x => x.ID == productDto.Recipient.PurchaserID);
|
||||
|
||||
if (purchaser != null)
|
||||
{
|
||||
productDto.Recipient.Purchaser = purchaser;
|
||||
}
|
||||
}
|
||||
|
||||
return productDtos;
|
||||
|
||||
Reference in New Issue
Block a user