public async Task <List <ShopServiceModel> > GetAllShopServicesAsync() { var entity = await shopServicesRepository.AsQueryable() .OrderByDescending(s => s.Id) .ToListAsync(); List <ShopServiceModel> result = new List <ShopServiceModel>(); foreach (var item in entity) { result.Add( new ShopServiceModel() { Id = item.Id, DescriptionService = item.DescriptionService, PriceService = item.Discounts == null ? item.PriceService : PriceHelper.GetPriceWithDiscount(item.PriceService, item.Discounts), ServicesName = item.ServicesName, Discount = PriceHelper.IsDiscountExpired(item.Discounts) } ); } return(result); }
public async Task <ShortShopServiceModel> GetShopServiceByIdAsync(int id) { var entity = await shopServicesRepository.GetByIdAsync(id); ShortShopServiceModel result = new ShortShopServiceModel() { Id = entity.Id, ServiceName = entity.ServicesName, ServicePrice = entity.Discounts == null ? entity.PriceService : PriceHelper.GetPriceWithDiscount(entity.PriceService, entity.Discounts), DescriptionService = entity.DescriptionService }; return(result); }
public async Task <List <ShopProductModel> > GetAllShopProductsAsync() { var entity = await _shopProductRepository.AsQueryable() .OrderByDescending(s => s.Id) .ToListAsync(); var result = new List <ShopProductModel>(); foreach (var item in entity) { result.Add( new ShopProductModel() { Id = item.Id, DescriptionProduct = item.DescriptionProduct, IsAvaliable = item.IsAvaliable, ManufacturerProduct = item.ManufacturerProduct, PriceProduct = item.Discounts == null ? item.PriceProduct : PriceHelper.GetPriceWithDiscount(item.PriceProduct, item.Discounts), ProductName = item.ProductName, TypeProdycts = EnumHelper.GetDescription(item.TypeProdyctsEnum), Discount = PriceHelper.IsDiscountExpired(item.Discounts) } ); } return(result); }