public ActionResult showUserHistory() { ViewBag.userName = Session["userName"]; ViewBag.logged = Session["LoggedIN"]; string uN = Request.Form["UsernameDropDown"]; ViewBag.userName = uN; IEnumerable <Buying_History> History = buyHistory.GetAllValues(uN); List <BuyingHisotyDetails> historyDetailsList = new List <BuyingHisotyDetails>(); foreach (Buying_History h in History) { BuyingHisotyDetails historyDetails = new BuyingHisotyDetails(); historyDetails.productID = h.Product_ID; historyDetails.productName = product.Get(h.Product_ID).Product_Name; historyDetails.productPrice = product.Get(h.Product_ID).Product_Price; historyDetails.prductPicture = product.Get(h.Product_ID).Product_Picture; historyDetails.buyingQuantity = h.Buying_Quantity; historyDetails.buyingDate = h.Buying_Date; historyDetails.userName = h.User_Name; historyDetailsList.Add(historyDetails); } return(View(historyDetailsList)); }
public ActionResult SelectItem(int productID) { ViewBag.userName = Session["userName"]; ViewBag.logged = Session["LoggedIN"]; //ViewBag.id = productID; iProduct_Service product = Service_Center.GetProduct_Service(); int catid = product.Get(productID).Category_ID; int subcatid = product.Get(productID).Sub_Category_ID; iCategory_Service cat = Service_Center.GetCategory_Service(); iSub_Category_Service sub = Service_Center.GetSub_Category_Service(); ViewBag.categoryName = cat.Get(catid).Category_Name; ViewBag.subcategoryName = sub.Get(subcatid).Sub_Category_Name; ViewBag.productPicture = Url.Content(product.Get(productID).Product_Picture); Session["SelectItemDetails"] = productID; if (product.Get(productID).Product_Quantity > 5) { ViewBag.productStatus = "In Stock"; } else { ViewBag.productStatus = "Out of Stock"; } return(View(product.Get(productID))); }
public ActionResult Edit(int id) { ViewBag.userName = Session["userName"]; ViewBag.logged = Session["LoggedIN"]; ViewBag.productName = product.Get(id).Product_Name; return(View(product.Get(id))); }
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")); } }
public ActionResult Index() { ViewBag.userName = Session["userName"]; ViewBag.logged = Session["LoggedIN"]; Product_Report re = Report.report(); ReportDetails reDetails = new ReportDetails(); reDetails.productName = product.Get(re.Product_ID).Product_Name; reDetails.category = category.Get(product.Get(re.Product_ID).Category_ID).Category_Name; reDetails.subCategory = subCategory.Get(product.Get(re.Product_ID).Sub_Category_ID).Sub_Category_Name; reDetails.productPicture = product.Get(re.Product_ID).Product_Picture; reDetails.productPrice = product.Get(re.Product_ID).Product_Price; reDetails.totalSellingQuantity = re.Selling_Quantity; int summation = 0, x = 0; IEnumerable <Product_Report> reportList = Report.GetAllValues(); foreach (Product_Report r in reportList) { x = product.Get(r.Product_ID).Product_Price *r.Selling_Quantity; summation += x; } ViewBag.totalSellingPrice = summation; return(View(reDetails)); }
// // 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()); }