public IActionResult AddMultipleToShoppingCart([FromServices] CartRelatedService service, int productid, int quantity, bool?buyNow) { var productselected = db.Products.FirstOrDefault(x => x.ProductId == productid); string customerid = Request.Cookies["customerId"]; string sessionid = Request.Cookies["sessionId"]; if (sessionid == null) { customerid = "0"; } if (productselected != null) { service.AddToCart(productselected, productid, quantity, customerid, sessionid); } if (buyNow == true) { return(RedirectToAction("Index", "Cart")); } else { return(RedirectToAction("ProductDetailPage", "Gallery", new { id = productid })); } }
public IActionResult Checkout([FromServices] CartRelatedService service) { ViewData["firstname"] = Request.Cookies["firstname"]; string sessionid = Request.Cookies["sessionId"]; ViewData["sessionId"] = sessionid; string customerId = Request.Cookies["customerId"]; ViewData["customerid"] = customerId; List <ShoppingCartItem> shoppingcart = db.ShoppingCartItem.Where(x => x.ShoppingCartId == customerId).ToList(); List <ShoppingCartItem> shoppingcartNull = db.ShoppingCartItem.Where(x => x.ShoppingCartId == "0").ToList(); if (sessionid != null) { ViewData["cartcount"] = shoppingcart.Count; ViewData["shoppingcartitems"] = shoppingcart; } else { ViewData["cartcount"] = shoppingcartNull.Count; ViewData["shoppingcartitems"] = shoppingcartNull; } service.CheckoutCart(customerId); service.ClearCart(customerId); return(RedirectToAction("CheckoutComplete")); }
public IActionResult AddSimilarToShoppingCart([FromServices] CartRelatedService service, int productid) { var productselected = db.Products.FirstOrDefault(x => x.ProductId == productid); string customerid = Request.Cookies["customerId"]; string sessionid = Request.Cookies["sessionId"]; if (sessionid == null) { customerid = "0"; } if (productselected != null) { service.AddToCart(productselected, productid, 1, customerid, sessionid); } return(RedirectToAction("ProductDetailPage", "Gallery", new { id = productid })); }
public IActionResult RemoveCartRow([FromServices] CartRelatedService service, int productid) { var productselected = db.Products.FirstOrDefault(x => x.ProductId == productid); string customerid = Request.Cookies["customerId"]; string sessionid = Request.Cookies["sessionId"]; if (sessionid == null) { customerid = "0"; } if (productselected != null) { service.RemoveRow(productselected, customerid, sessionid); } return(RedirectToAction("Index", "Cart")); }
public IActionResult AddInDesign([FromServices] CartRelatedService service, int productid) { var productselected = db.Products.FirstOrDefault(x => x.ProductId == productid); string customerid = Request.Cookies["customerId"]; string sessionid = Request.Cookies["sessionId"]; if (sessionid == null) { customerid = "0"; } if (productselected != null) { service.AddToCart(productselected, productid, 1, customerid, sessionid); } return(RedirectToAction("DesignAndIllustration", "Gallery")); }