// // GET: /Cart/ public ActionResult Index() { if (Convert.ToBoolean(Session["LoggedIN"]) == true) { ViewBag.userName = Session["userName"]; ViewBag.logged = Session["LoggedIN"]; iCart_Service cart = Service_Center.GetCart_Service(); int totalSum = 0; IEnumerable <Cart> CartAll = cart.Get(Session["userName"].ToString()); foreach (Cart c in CartAll) { int sum = c.BuyingQuantity * c.ProductPrice; totalSum += sum; } ViewBag.totalPrice = totalSum; return(View(cart.Get(Session["userName"].ToString()))); } else { return(RedirectToAction("Index", "userAuthentication")); } }
public ActionResult fullCartDelete() { iCart_Service cart = Service_Center.GetCart_Service(); int de = cart.DeleteUserCart(Session["userName"].ToString()); return(RedirectToAction("Index", "Home")); }
public ActionResult Delete(int id) { iCart_Service cart = Service_Center.GetCart_Service(); int i = cart.DeleteItem(id); return(RedirectToAction("Index")); }
public ActionResult UpdateIncreaseOne(int id) { iCart_Service cart = Service_Center.GetCart_Service(); Cart c = new Cart(); c.Id = id; c.BuyingQuantity = cart.GetbyID(id).BuyingQuantity + 1; int i = cart.Update(c); return(RedirectToAction("Index")); }
public ActionResult UpdateDecresceOne(int id) { iCart_Service cart = Service_Center.GetCart_Service(); Cart c = new Cart(); if (cart.GetbyID(id).BuyingQuantity > 1) { c.Id = id; c.BuyingQuantity = cart.GetbyID(id).BuyingQuantity - 1; int i = cart.Update(c); return(RedirectToAction("Index")); } else { int i = cart.DeleteItem(id); return(RedirectToAction("Index")); } }
public ActionResult AddingToCart() { if (Convert.ToBoolean(Session["LoggedIN"]) == true) { iCart_Service cartService = Service_Center.GetCart_Service(); iProduct_Service product = Service_Center.GetProduct_Service(); iCategory_Service cat = Service_Center.GetCategory_Service(); iSub_Category_Service sub = Service_Center.GetSub_Category_Service(); int productID = Convert.ToInt32(Session["SelectItemDetails"]); int catid = product.Get(productID).Category_ID; int subcatid = product.Get(productID).Sub_Category_ID; Cart cart = new Cart(); cart.ProductID = productID; cart.ProductName = product.Get(productID).Product_Name; cart.ProductCategory = cat.Get(catid).Category_Name; cart.ProductSubCategory = sub.Get(subcatid).Sub_Category_Name; cart.ProductPicture = product.Get(productID).Product_Picture; cart.ProductPrice = product.Get(productID).Product_Price; cart.BuyingQuantity = Convert.ToInt32(Request.Form["quantityItem"]); cart.Username = Session["userName"].ToString(); int i = cartService.Insert(cart); if (i == 1) { return(RedirectToAction("Index", "Cart")); } else { return(RedirectToAction("Index", "Home")); } } else { return(RedirectToAction("Index", "userAuthentication")); } }
// // GET: /BuyingConfimation/ public ActionResult Index() { ViewBag.userName = Session["userName"]; ViewBag.logged = Session["LoggedIN"]; iCart_Service cart = Service_Center.GetCart_Service(); iProduct_Service productAll = Service_Center.GetProduct_Service();// iBuying_History_Service buyingHistory = Service_Center.GetBuying_History_Service(); iProduct_Report_Service report = Service_Center.GetProduct_Report_Service(); IEnumerable <Cart> FullCart = cart.Get(Session["userName"].ToString()); foreach (Cart c in FullCart) { Product pro = new Product(); IEnumerable <Product> proAll = productAll.GetAllValues(); foreach (Product p in proAll) { if (p.Id == c.ProductID) { int before = productAll.Get(p.Id).Product_Quantity; int after = before - c.BuyingQuantity; pro.Id = p.Id; pro.Product_Quantity = after; int y = productAll.Update(pro); } } Buying_History buy = new Buying_History(); Product_Report rep = new Product_Report(); buy.Product_ID = c.ProductID; buy.User_Name = Session["userName"].ToString(); buy.Buying_Quantity = c.BuyingQuantity; buy.Buying_Date = DateTime.Now.ToLocalTime(); IEnumerable <Product_Report> proReport = report.GetAllValues(); bool check = false; int productID = 0; foreach (Product_Report r in proReport) { if (r.Product_ID == c.ProductID) { check = true; productID = r.Product_ID; break; } } if (check == true) { int beforeQuantity = report.Get(productID).Selling_Quantity; int afterQuantity = beforeQuantity + c.BuyingQuantity; rep.Product_ID = productID; rep.Selling_Quantity = afterQuantity; int p = report.Update(rep); } else { rep.Product_ID = c.ProductID; rep.Selling_Quantity = c.BuyingQuantity; int j = report.Insert(rep); } int i = buyingHistory.Insert(buy); } int de = cart.DeleteUserCart(Session["userName"].ToString()); //ViewBag.row = cartRow; return(View()); }