public async Task <ActionResult> RemoveFromCart(int?serviceId) { try { var service = _serviceLogic.MapServiceToServiceView(await _serviceLogic.FindServiceWithDiscount(serviceId)); return(PartialView("DeleteServiceFromShopCartModalView", service)); } catch (ArgumentNullException) { return(RedirectToAction("Index", new { message = SystemMessages.Error })); } catch (NullReferenceException) { return(RedirectToAction("Index", new { message = SystemMessages.Error })); } }
public async Task <List <ServiceView> > GetRelevantDiscountsForHomePage() { var servicesWithDiscount = await _db.Services.Include(s => s.Discount).ToListAsync(); var result = new List <ServiceView>(); foreach (var item in servicesWithDiscount) { if (item.Discount != null) { if (item.Discount.isRelevant()) { result.Add(_servicesLogic.MapServiceToServiceView(item)); } } } return(result); }