// GET: Cart public ActionResult Index() { try { if (Session["idUser"] != null) { var cartData = CustomerCartCRUD.GetCartByCustomerId(Convert.ToInt32(Session["idUser"])); cartData = cartData.Where(x => x.IsPlace == false).ToList(); ViewBag.totalAmount = cartData.Sum(x => x.Amount).ToString(); return(View(cartData)); } else { return(RedirectToAction("Login", "Customer")); } } catch (Exception ex) { ExceptionLogDomain obj = new ExceptionLogDomain(); obj.MethodName = "Index"; obj.ControllerName = "Cart"; obj.ErrorText = ex.Message; obj.StackTrace = ex.StackTrace; obj.Datetime = DateTime.Now; ExceptionLogCRUD.AddToExceptionLog(obj); return(RedirectToAction("Index", "Error")); } }
public ActionResult TopSearchBar() { try { //"1" is customerid if (Session["idUser"] != null) { ViewBag.totalItemsInCart = CustomerCartCRUD.GetCartByCustomerId(Convert.ToInt32(Session["idUser"])).Where(x => x.IsPlace == false).Count(); ViewBag.totalItemsInWishList = CustmorWishlistCRUD.GetWishlistByCustomerId(Convert.ToInt32(Session["idUser"])).Count(); } else { ViewBag.totalItemsInCart = 0; ViewBag.totalItemsInWishList = 0; } return(PartialView("_TopSearchMenu")); } catch (Exception ex) { ExceptionLogDomain obj = new ExceptionLogDomain(); obj.MethodName = "TopSearchBar"; obj.ControllerName = "Menu"; obj.ErrorText = ex.Message; obj.StackTrace = ex.StackTrace; obj.Datetime = DateTime.Now; ExceptionLogCRUD.AddToExceptionLog(obj); return(RedirectToAction("Index", "Error")); } }
// GET: checkout public ActionResult Index() { try { if (Session["idUser"] != null) { CheckoutDomain mCheckoutDomain = new CheckoutDomain(); List <CustomerCartDomain> customercartList = new List <CustomerCartDomain>(); var customerCartOrders = CustomerCartCRUD.GetCartByALLCustomerId(Convert.ToInt32(Session["idUser"])); mCheckoutDomain.Id = customerCartOrders[0].Id; mCheckoutDomain.FirstName = customerCartOrders[0].FirstName; mCheckoutDomain.LastName = customerCartOrders[0].LastName; mCheckoutDomain.Email = customerCartOrders[0].Email; mCheckoutDomain.Phone = customerCartOrders[0].Phone; mCheckoutDomain.Country = customerCartOrders[0].Country; mCheckoutDomain.State = customerCartOrders[0].State; mCheckoutDomain.City = customerCartOrders[0].City; mCheckoutDomain.Pincode = customerCartOrders[0].Pincode; mCheckoutDomain.ShippingAddress = customerCartOrders[0].ShippingAddress; mCheckoutDomain.BillingAddress = customerCartOrders[0].BillingAddress; for (int i = 0; i < customerCartOrders.Count(); i++) { CustomerCartDomain mObj = new CustomerCartDomain(); mObj.Amount = customerCartOrders[i].Amount; mObj.Quantity = customerCartOrders[i].Quantity; mObj.ITEM_DESC = customerCartOrders[i].ProductName; mObj.Id = customerCartOrders[i].cartId; mObj.IsPlace = customerCartOrders[i].IsPlaced; customercartList.Add(mObj); } ViewBag.CustomerscartList = customercartList.Where(x => x.IsPlace == false).ToList(); Session["customerCartOrders"] = customercartList; ViewBag.Subtotal = customercartList.Where(x => x.IsPlace == false).Sum(x => x.Amount); return(View(mCheckoutDomain)); } else { return(RedirectToAction("Login", "Customer")); } } catch (Exception ex) { ExceptionLogDomain obj = new ExceptionLogDomain(); obj.MethodName = "Index"; obj.ControllerName = "Checkout"; obj.ErrorText = ex.Message; obj.StackTrace = ex.StackTrace; obj.Datetime = DateTime.Now; ExceptionLogCRUD.AddToExceptionLog(obj); return(RedirectToAction("Index", "Error")); } }
public ActionResult CustomersOrders() { int custid = Convert.ToInt32(Session["idUser"]); if (custid != 0) { var data = CustomerCartCRUD.GetCartByCustomerId(custid); return(View(data)); } else { return(RedirectToAction("Login")); } }
public ActionResult PlaceOrder(CustomerOrderDomain model) { try { var orders = CustomerOrderCRUD.GetCustomerOrderByCustomerId(0); int lastOrder = 0; if (orders.Count > 1) { lastOrder = orders[0].Id; } model.OrderDate = DateTime.Now; model.PaymentType = "COD"; model.TransactionId = "Trans00" + lastOrder + 1; CustomerOrderCRUD.AddToCustomerOrder(model); List <CustomerCartDomain> sessionCustomerCartOrders = (List <CustomerCartDomain>)Session["customerCartOrders"]; if (sessionCustomerCartOrders != null) { foreach (var item in sessionCustomerCartOrders) { bool res = CustomerCartCRUD.UpdateDetails(item.Id, true); } } else { var customerCartOrders = CustomerCartCRUD.GetCartByALLCustomerId(Convert.ToInt32(Session["idUser"])); foreach (var item in customerCartOrders) { bool res = CustomerCartCRUD.UpdateDetails(item.Id, true); } } return(Json("True", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ExceptionLogDomain obj = new ExceptionLogDomain(); obj.MethodName = "PlaceOrder"; obj.ControllerName = "Checkout"; obj.ErrorText = ex.Message; obj.StackTrace = ex.StackTrace; obj.Datetime = DateTime.Now; ExceptionLogCRUD.AddToExceptionLog(obj); return(Json("False", JsonRequestBehavior.AllowGet)); } }
public ActionResult Index() { ViewBag.BrandOnHomePage = BrandmasterCRUD.GetBrandMaster().Where(x => x.IsOnHomePage == true); if (Session["idUser"] != null) { ViewBag.totalItemsInCart = CustomerCartCRUD.GetCartByCustomerId(Convert.ToInt32(Session["idUser"])).Where(x => x.IsPlace == false).Count(); ViewBag.totalItemsInWishList = CustmorWishlistCRUD.GetWishlistByCustomerId(Convert.ToInt32(Session["idUser"])).Count(); } else { ViewBag.totalItemsInCart = 0; ViewBag.totalItemsInWishList = 0; } return(View()); }
// GET: Order public ActionResult Index() { try { if (Session["idUser"] != null) { int customerID = Convert.ToInt32(Session["idUser"]); var orders = CustomerOrderCRUD.GetCustomerOrderByCustomerId(customerID); List <Domain.CustomerCartDomain> customercartList = new List <Domain.CustomerCartDomain>(); var customerOrders = CustomerCartCRUD.GetCartByALLCustomerId(Convert.ToInt32(Session["idUser"])); for (int i = 0; i < customerOrders.Count(); i++) { Domain.CustomerCartDomain mObj = new Domain.CustomerCartDomain(); mObj.Amount = customerOrders[i].Amount; mObj.Quantity = customerOrders[i].Quantity; mObj.ITEM_DESC = customerOrders[i].ProductName; mObj.Id = customerOrders[i].cartId; customercartList.Add(mObj); } ViewBag.CustomerscartList = customercartList; return(View(orders)); } else { return(RedirectToAction("Login", "Customer")); } } catch (Exception ex) { ExceptionLogDomain obj = new ExceptionLogDomain(); obj.MethodName = "Index"; obj.ControllerName = "Order"; obj.ErrorText = ex.Message; obj.StackTrace = ex.StackTrace; obj.Datetime = DateTime.Now; ExceptionLogCRUD.AddToExceptionLog(obj); return(RedirectToAction("Index", "Error")); } }
public ActionResult DeleteCartItem(int cartId) { try { var result = CustomerCartCRUD.DeleteCartItem(cartId); return(RedirectToAction("Index")); } catch (Exception ex) { ExceptionLogDomain obj = new ExceptionLogDomain(); obj.MethodName = "Index"; obj.ControllerName = "Cart"; obj.ErrorText = ex.Message; obj.StackTrace = ex.StackTrace; obj.Datetime = DateTime.Now; ExceptionLogCRUD.AddToExceptionLog(obj); return(RedirectToAction("Index", "Error")); } }
public ActionResult AddToCart(string prodId, string price, string qty) { try { if (Session["idUser"] != null) { Session["QTY"] = qty; CustomerCartDomain mcustomerCart = new CustomerCartDomain(); mcustomerCart.Amount = Convert.ToDecimal(price) * Convert.ToInt32(qty); mcustomerCart.CreatedDatetime = DateTime.Now; mcustomerCart.CustomerId = Session["idUser"].ToString(); mcustomerCart.IsDeleted = "False"; mcustomerCart.Quantity = Convert.ToInt32(qty); mcustomerCart.ProductId = prodId; mcustomerCart.IsPlace = false; CustomerCartCRUD.AddToCart(mcustomerCart); return(Json(true)); } else { return(Json(false)); } } catch (Exception ex) { ExceptionLogDomain obj = new ExceptionLogDomain(); obj.MethodName = "AddToCart"; obj.ControllerName = "Product"; obj.ErrorText = ex.Message; obj.StackTrace = ex.StackTrace; obj.Datetime = DateTime.Now; ExceptionLogCRUD.AddToExceptionLog(obj); return(RedirectToAction("Index", "Error")); } }