public ActionResult CheckOut(string message) { if (User.IsInRole("Admin")) { RedirectToAction("Index", "Home"); } if (message != null) { ViewBag.message = message; } OrderViewModel objOrderViewModel = new OrderViewModel(); if (Session["CartID"] != null) { string CartID = Session["CartID"].ToString(); String ApplicationUserID = User.Identity.GetUserId(); objOrderViewModel.Email = User.Identity.GetUserName(); objOrderViewModel.Customer = db.Customer.Where(m => m.ApplicationUserID == ApplicationUserID).FirstOrDefault(); objOrderViewModel.PaymentInfo = db.PaymentInfo.Where(m => m.CustomerID == objOrderViewModel.Customer.ID).FirstOrDefault(); objOrderViewModel.Cart = db.Cart.Include("Products").Where(m => m.cartID == CartID).ToList(); int subtotal = db.Cart.Where(m => m.cartID == CartID).Select(g => g.Price).Sum(); objOrderViewModel.Subtotal = subtotal; ViewBag.CreditCard = new SelectList(db.PaymentInfo.Where(m => m.CustomerID == objOrderViewModel.Customer.ID), "ID", "CartNumber"); return View(objOrderViewModel); } else { return RedirectToAction("Index", "Home"); } }
public ActionResult Dashboard(string panel) { ViewBag.panel = "edit"; OrderViewModel objOrderViewModel = new OrderViewModel(); if (panel != null) { ViewBag.panel = panel; if (panel == "paymentinfo") { string applicationuserid1 = User.Identity.GetUserId(); int CustID = db.Customer.Where(m => m.ApplicationUserID == applicationuserid1).FirstOrDefault().ID; objOrderViewModel.PaymentInfo = db.PaymentInfo.Where(m => m.CustomerID == CustID).FirstOrDefault(); } if (panel == "ListPaymentInfo") { string applicationuserid1 = User.Identity.GetUserId(); int CustID = db.Customer.Where(m => m.ApplicationUserID == applicationuserid1).FirstOrDefault().ID; objOrderViewModel.cPaymentInfo = db.PaymentInfo.Where(m => m.CustomerID == CustID).ToList(); } } string applicationuserid = User.Identity.GetUserId(); objOrderViewModel.Customer= db.Customer.Where(m => m.ApplicationUserID == applicationuserid).FirstOrDefault(); return View(objOrderViewModel); }
public ActionResult EditCustomerDetails() { OrderViewModel objOrderViewModel = new OrderViewModel(); ViewBag.panel ="edit"; string applicationuserid = User.Identity.GetUserId(); objOrderViewModel.Customer = db.Customer.Where(m => m.ApplicationUserID == applicationuserid).FirstOrDefault(); return PartialView("PartialDashboard", objOrderViewModel); }
//[ChildActionOnlyAttribute] //public ActionResult RenderOrders(string CartID) //{ // OrderViewModel objOrderViewModel = new OrderViewModel(); // objOrderViewModel.Cart= db.Cart.Include("Products").Where(m => m.cartID == CartID).ToList(); // int subtotal= db.Cart.Where(m => m.cartID == CartID).Select(g => g.Price).Sum(); // objOrderViewModel.Subtotal = Convert.ToInt16(subtotal); // return PartialView(objOrderViewModel); //} public ActionResult CheckOrders(string CartID) { OrderViewModel objOrderViewModel = new OrderViewModel(); Cart objCart = new Cart(); var result = db.Cart.Include("Products").Where(m => m.cartID == CartID ).ToList(); var CustomerID = db.Orders.Where(m => m.CartID == CartID).FirstOrDefault().CustomerID; ViewBag.Customer = db.Customer.Find(CustomerID); ViewBag.Total =db.Cart.Where(m => m.cartID == CartID).Select(g => g.Price).Sum(); return View(result.ToList()); }
public ActionResult ProductsBought() { ViewBag.panel = "productsbought"; string applicationuserid = User.Identity.GetUserId(); int CustID = db.Customer.Where(m => m.ApplicationUserID == applicationuserid).FirstOrDefault().ID; OrderViewModel objOrderViewModel = new OrderViewModel(); objOrderViewModel.cOrders = db.Orders.Where(m => m.CustomerID == CustID).ToList(); // objOrderViewModel.Cart = db.Cart.Include("Products").Where(m => m.cartID == objOrderViewModel.Orders.CartID).ToList(); return PartialView("PartialDashboard", objOrderViewModel); }
//List Payement Options public ActionResult ListPaymentOption() { /* string applicationuserid1 = User.Identity.GetUserId(); int CustID = db.Customer.Where(m => m.ApplicationUserID == applicationuserid1).FirstOrDefault().ID; objOrderViewModel.cPaymentInfo = db.PaymentInfo.Where(m => m.CustomerID == CustID ).ToList(); */ string applicationuserid1 = User.Identity.GetUserId(); OrderViewModel objOrderViewModel = new OrderViewModel(); int CustID = db.Customer.Where(m => m.ApplicationUserID == applicationuserid1).FirstOrDefault().ID; objOrderViewModel.cPaymentInfo = db.PaymentInfo.Where(m => m.CustomerID == CustID).ToList(); ViewBag.panel = "ListPaymentInfo"; return PartialView("PartialDashboard",objOrderViewModel); }
public ActionResult CustomerInfo(OrderViewModel OrderViewModel) { // string name = formCollection["txtname"].ToString(); if (ModelState.IsValid) { int CustomerID = OrderViewModel.Customer.ID; var result = db.Customer.Find(CustomerID); result.FirstName = OrderViewModel.Customer.FirstName; result.LastName = OrderViewModel.Customer.LastName; result.Address = OrderViewModel.Customer.Address; result.PhoneNumber = OrderViewModel.Customer.PhoneNumber; result.City = OrderViewModel.Customer.City; result.State = OrderViewModel.Customer.State; result.Country = OrderViewModel.Customer.Country; db.SaveChanges(); } return PartialView(); }
// // GET: /Admin/ public ActionResult Index() { OrderViewModel objOrderViewModel = new OrderViewModel(); objOrderViewModel.cOrders = db.Orders.OrderByDescending(m=>m.OrderID).ToList(); return View(objOrderViewModel); }