public int CartCount() { try { BLCustomer bal = new BLCustomer(); int count = 0; if (Session["CustomerId"] != null) { int CustomerId = Convert.ToInt32(Session["CustomerId"]); int CartId = bal.CartCustomerExist(CustomerId); List <DLProducts> lst = bal.CartItem(CartId); foreach (var v in lst) { count++; } Session["CartCount"] = count; } return(count); } catch (Exception ex) { throw ex; } }
public ActionResult AddCart(int id) { try { if (Session["CustomerId"] != null) { int CustomerId = Convert.ToInt32(Session["CustomerId"]); int CartId = balCustomer.CartCustomerExist(CustomerId); if (CartId == 0) { bool addCart = balCustomer.AddCart(CustomerId); CartId = balCustomer.CartCustomerExist(CustomerId); } bool ProductIdExist = balCustomer.CartProductExist(CartId, id); if (ProductIdExist) { if (!balCustomer.AddQuantity(CartId, id)) { TempData["Error"] = "Product out of stock..."; } } else { if (!balCustomer.AddCartItem(CartId, id)) { TempData["Error"] = "Product out of stock..."; } } } else { TempData["Error"] = "Please SignIn first..."; } //Session["CartCount"] = CartCount(); return(Redirect("/Clothes/Clothes")); } catch (Exception ex) { throw ex; } }
public ActionResult SignIn(string Email, string Password) { try { bal = new BLCustomer(); if (!string.IsNullOrEmpty(Email) && !string.IsNullOrEmpty(Password)) { string email = Request["Email"]; string password = SHA1.Encode(Password); string[] i = bal.SignIn(email, password); if (i != null) { Session["LoginCustomer"] = i[0]; Session["CustomerId"] = i[1]; if (Session["CustomerId"] != null) { int CustomerId = Convert.ToInt32(Session["CustomerId"]); int CartId = bal.CartCustomerExist(CustomerId); List <DLProducts> lst = bal.CartItem(CartId); int count = 0; foreach (var val in lst) { count++; } Session["CartCount"] = count; } return(Redirect("/Customer/Home")); } else { TempData["Error"] = "Invalid email or password"; } } else { TempData["Error"] = "Required Email or password"; } return(Redirect("/Customer/Home")); } catch (Exception ex) { throw ex; } }
public ActionResult CheckOut() { int CustomerId = Convert.ToInt32(Session["CustomerId"]); int CartId = balCustomer.CartCustomerExist(CustomerId); if (balOrder.CartOrder(CartId, CustomerId)) { Session["CartCount"] = 0; return(Redirect("/Order/OrderList")); } else { TempData["Error"] = "No Product in your Cart"; return(Redirect("/Clothes/Clothes")); } }
public ActionResult Login() { try { bal = new BLCustomer(); DLCustomer dlcustomer = new DLCustomer(); dlcustomer.Firstname = Request["Firstname"]; dlcustomer.Lastname = Request["Lastname"]; dlcustomer.GoogleId = Request["GoogleID"]; dlcustomer.Email = Request["Email"]; Session["LoginCustomer"] = dlcustomer.Firstname + " " + dlcustomer.Lastname; dlcustomer.Password = null; int val = bal.Signup(dlcustomer, "Insert"); Session["CustomerId"] = bal.GPlusCustomer(); if (Session["CustomerId"] != null) { int CustomerId = Convert.ToInt32(Session["CustomerId"]); int CartId = bal.CartCustomerExist(CustomerId); if (CartId > 0) { List <DLProducts> lst = bal.CartItem(CartId); int count = 0; foreach (var v in lst) { count++; } Session["CartCount"] = count; } } return(Redirect("/Customer/Home")); } catch (Exception ex) { throw ex; } }