public ActionResult Cart() { try { if (Session["BeEdited"] != null) { MvcApplication.changeStatusNotifer.Dispose(); string dependencyCheckSql = string.Format("{0}{1}", "SELECT OrderStatus FROM dbo.[Orders] WHERE CustomerUserId=", (int)Session["UserId"]); MvcApplication.changeStatusNotifer.Start("BMAChangeDB", dependencyCheckSql); MvcApplication.changeStatusNotifer.Change += this.OnChange3; } CustomerOrderBusiness cob = new CustomerOrderBusiness(); int quantity = 0; if (Session["Cart"] == null || Session["UserRole"] != null) { return RedirectToAction("Index", "Product"); } ViewBag.taxRate = cob.GetTaxRate(); List<CustomerCartViewModel> lstCart = GetCart(); if (lstCart.Count == 0) { return RedirectToAction("Index", "Product"); } List<DiscountByQuantity> dbq = db.DiscountByQuantities.ToList(); Policy policy = db.Policies.SingleOrDefault(n => n.PolicyId == 1); ViewBag.policy = policy; foreach (var item in lstCart) { quantity += item.Quantity; } if (dbq[0].beUsing) { TempData["Discount"] = cob.checkDiscount(quantity); return View(lstCart); } else { return View(lstCart); } } catch { return RedirectToAction("Index", "Error"); } }
public ActionResult OrderDetail(int orderId) { try { CusManageBusiness cmb = new CusManageBusiness(); CustomerOrderBusiness cob = new CustomerOrderBusiness(); int quantity = 0; var order = cmb.GetOrderDetail(orderId); if (order.CustomerUserId != Convert.ToInt32(Session["UserId"])) { return RedirectToAction("Index", "Home"); } var orderItems = cmb.GetOrderItem(orderId); ViewBag.taxRate = cob.GetTaxRate(); ViewBag.orderItems = orderItems; foreach (var item in orderItems) { quantity += item.Quantity; } ViewBag.Discount = cob.checkDiscount(quantity); return View(order); } catch (Exception) { return RedirectToAction("Index", "Error"); } }
//public int GetDateAndNote(string planDeliveryDate, string Note) //{ // try // { // Session["DeliveryDate"] = planDeliveryDate; // Session["Note"] = Note; // return 1; // } // catch // { // return -1; // } //} public ActionResult ProceedCheckout(FormCollection f) { try { CustomerOrderBusiness cob = new CustomerOrderBusiness(); int quantity = 0; if (Session["Cart"] == null) { return RedirectToAction("Index", "Home"); } ViewBag.taxRate = cob.GetTaxRate(); string planDeliveryDate = f["txtDelivery"].ToString(); Session["DeliveryDate"] = planDeliveryDate; string Note = f["txtNote"]; Session["Note"] = Note; List<CustomerCartViewModel> lstCart = GetCart(); foreach (var item in lstCart) { if (!cob.IsActiveProduct(item.ProductId)) { ViewBag.productName = item.ProductName; } } if (lstCart.Count == 0) { return RedirectToAction("Index", "Product"); } List<Boolean> dbq = db.DiscountByQuantities.Select(n => n.beUsing).ToList(); foreach (var item in lstCart) { quantity += item.Quantity; } if (dbq[0]) { TempData["Discount"] = cob.checkDiscount(quantity); } else { } return View(lstCart); } catch { return RedirectToAction("Index", "Error"); } }
public ActionResult ConfirmOrder(int orderId) { try { CusManageBusiness cmb = new CusManageBusiness(); CustomerOrderBusiness cob = new CustomerOrderBusiness(); int quantityConfirm = 0; int quantityOld = 0; var orderCheck = cmb.GetOrderDetail(orderId); if (orderCheck.CustomerUserId != Convert.ToInt32(Session["UserId"])) { return RedirectToAction("Index", "Home"); } Order confirmedOrder = cmb.GetOrderDetail(orderId); List<OrderItem> orderItems = cmb.GetOrderItem(orderId); int? previousId = confirmedOrder.PreviousOrderId; Order oldOrder = cmb.GetOrderDetail(previousId); List<OrderItem> oldOrderItems = cmb.GetOrderItem(previousId); foreach (var item in orderItems) { quantityConfirm += item.Quantity; } ViewBag.DiscountConfirm = cob.checkDiscount(quantityConfirm); foreach (var item in oldOrderItems) { quantityOld += item.Quantity; } ViewBag.DiscountOld = cob.checkDiscount(quantityOld); ViewBag.taxRate = cob.GetTaxRate(); ViewBag.oldOrder = oldOrder; ViewBag.orderItems = orderItems; ViewBag.oldOrderItems = oldOrderItems; return View(confirmedOrder); } catch (Exception) { return RedirectToAction("Index", "Error"); } }