public ActionResult Index(string id) { var product = DataHelper.Get(id); var loginCookie = Request.Cookies["login"]; return(View(new ProductPageViewModel { Basket = BasketHelper.Get(), Product = product, LoginName = loginCookie != null && loginCookie.Value != "" ? loginCookie.Value: null, ErrorMessage = TempData["error-message"] as string, MoreLikeThis = DataHelper.MoreLike(id), })); }
public ActionResult Add(string productId) { var loginCookie = Request.Cookies["login"]; if (loginCookie == null || string.IsNullOrEmpty(loginCookie.Value)) { throw new UserNotLoggedInOnAddingToBasketException(); } var product = DataHelper.Get(productId); if (!BasketHelper.Add(product)) { TempData.Add("error-message", "Sorry we could not add this item to your basket."); } return(RedirectToAction("index", "product", new { id = productId })); }