fixes
This commit is contained in:
parent
254211459f
commit
a8a84def54
|
|
@ -249,21 +249,21 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
|
|||
public async Task<List<ProductDto>> GetProductDtos()
|
||||
{
|
||||
_logger.Detail($"GetProductDtos invoked");
|
||||
return await ctx.GetAllProductDtos(false).ToListAsync();
|
||||
return await ctx.ProductDtos.GetAll(false).ToListAsync();
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.GetAllMeasuringProductDtos)]
|
||||
public async Task<List<MeasuringProductDto>> GetAllMeasuringProductDtos()
|
||||
{
|
||||
_logger.Detail($"GetAllMeasuringProductDtos invoked");
|
||||
return await ctx.GetAllMeasuringProductDtos(false).ToListAsync();
|
||||
}
|
||||
//[SignalR(SignalRTags.GetAllMeasuringProductDtos)]
|
||||
//public async Task<List<MeasuringProductDto>> GetAllMeasuringProductDtos()
|
||||
//{
|
||||
// _logger.Detail($"GetAllMeasuringProductDtos invoked");
|
||||
// return await ctx.GetAllMeasuringProductDtos(false).ToListAsync();
|
||||
//}
|
||||
|
||||
[SignalR(SignalRTags.GetMeasuringProductDtoById)]
|
||||
public async Task<MeasuringProductDto?> GetMeasuringProductDtoById(int productId)
|
||||
public async Task<ProductDto?> GetProductDtoById(int productId)
|
||||
{
|
||||
_logger.Detail($"GetMeasuringProductDtoById invoked; productId: {productId}");
|
||||
return await ctx.GetMeasuringProductDtoByIdAsync(productId);
|
||||
_logger.Detail($"GetProductDtoById invoked; productId: {productId}");
|
||||
return await ctx.ProductDtos.GetByIdAsync(productId, true);
|
||||
}
|
||||
|
||||
[SignalR(SignalRTags.AuthenticateUser)]
|
||||
|
|
|
|||
|
|
@ -119,20 +119,20 @@ public class FruitBankDbContext : MgDbContextBase,
|
|||
return query.Distinct();
|
||||
}
|
||||
|
||||
public IQueryable<Product> GetAllProducts(bool includeDeleted)
|
||||
=> Products.Table.Where(p => includeDeleted || !p.Deleted).OrderBy(o => o.Name);
|
||||
//public IQueryable<Product> GetAllProducts(bool includeDeleted)
|
||||
// => Products.Table.Where(p => includeDeleted || !p.Deleted).OrderBy(o => o.Name);
|
||||
|
||||
public IQueryable<ProductDto> GetAllProductDtos(bool includeDeleted)
|
||||
=> GetAllProducts(includeDeleted).Select(product => new ProductDto(product));
|
||||
//public IQueryable<ProductDto> GetAllProductDtos(bool includeDeleted)
|
||||
// => GetAllProducts(includeDeleted).Select(product => new ProductDto(product));
|
||||
|
||||
public IAsyncEnumerable<MeasuringProductDto> GetAllMeasuringProductDtos(bool includeDeleted)
|
||||
=> GetAllProducts(includeDeleted).AsEnumerable().SelectAwait(async product => new MeasuringProductDto(product, await GetMeasuringAttributeValuesByProductIdAsync(product.Id)));
|
||||
//public IAsyncEnumerable<MeasuringProductDto> GetAllMeasuringProductDtos(bool includeDeleted)
|
||||
// => GetAllProducts(includeDeleted).AsEnumerable().SelectAwait(async product => new MeasuringProductDto(product, await GetMeasuringAttributeValuesByProductIdAsync(product.Id)));
|
||||
|
||||
public async Task<MeasuringProductDto?> GetMeasuringProductDtoByIdAsync(int productId)
|
||||
=> await Products.Table.Where(product => product.Id == productId).AsEnumerable().SelectAwait(async product => new MeasuringProductDto(product, await GetMeasuringAttributeValuesByProductIdAsync(product.Id))).FirstOrDefaultAsync();
|
||||
//public async Task<MeasuringProductDto?> GetMeasuringProductDtoByIdAsync(int productId)
|
||||
// => await Products.Table.Where(product => product.Id == productId).AsEnumerable().SelectAwait(async product => new MeasuringProductDto(product, await GetMeasuringAttributeValuesByProductIdAsync(product.Id))).FirstOrDefaultAsync();
|
||||
|
||||
public async Task<MeasuringAttributeValues?> GetMeasuringAttributeValuesByProductIdAsync(int productId)
|
||||
=> await _fruitBankAttributeService.GetMeasuringAttributeValuesAsync<Product>(productId);
|
||||
//public async Task<MeasuringAttributeValues?> GetMeasuringAttributeValuesByProductIdAsync(int productId)
|
||||
// => await _fruitBankAttributeService.GetMeasuringAttributeValuesAsync<Product>(productId);
|
||||
|
||||
public async Task DeleteShippingSafeAsync(Shipping shipping)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,12 +17,13 @@ public class ProductDtoDbTable : MgDtoDbTableBase<ProductDto, Product>
|
|||
{
|
||||
}
|
||||
|
||||
public IQueryable<ProductDto> GetAll(bool loadRelations)
|
||||
public IQueryable<ProductDto> GetAll(bool loadRelations, bool includeDeleted = false)
|
||||
{
|
||||
return GetAll().LoadWith(p => p.GenericAttributes);
|
||||
return GetAll().Where(p => includeDeleted || !p.Deleted)
|
||||
.LoadWith(p => p.GenericAttributes);
|
||||
}
|
||||
|
||||
public Task<ProductDto> GetByIdAsync(int productId, bool loadRelations) => GetAll(loadRelations).Where(x => x.Id == productId).FirstOrDefaultAsync(null);
|
||||
public Task<ProductDto> GetByIdAsync(int productId, bool loadRelations, bool includeDeleted = false) => GetAll(loadRelations).Where(x => x.Id == productId).FirstOrDefaultAsync(null);
|
||||
|
||||
public IQueryable<ProductDto> GetAllByIds(IEnumerable<int> productIds, bool loadRelations = true) => GetAll(loadRelations).Where(p => productIds.Contains(p.Id));
|
||||
public IQueryable<ProductDto> GetAllByIds(IEnumerable<int> productIds, bool loadRelations = true, bool includeDeleted = false) => GetAll(loadRelations).Where(p => productIds.Contains(p.Id));
|
||||
}
|
||||
Loading…
Reference in New Issue