public ActionResult AddToCart(int id) { List <Models.ModelView.ProductView> pro = new List <Models.ModelView.ProductView>(); Models.IRepository <Models.ModelView.ProductView> product = Models.Dao.ProductDao.Instance; var q = product.GetId(id); if (Session["Cart"] == null) { List <Models.ModelView.CartView> Cart = new List <Models.ModelView.CartView>(); Session["Cart"] = Cart; } var cart = (List <Models.ModelView.CartView>)Session["Cart"]; var count = 0; foreach (var item in cart) { if (q.name_product == item.product) { item.quantity += 1; item.subtotal = (item.quantity * item.price); count++; return(RedirectToAction("checkout")); } } if (count == 0) { cart.Add(new Models.ModelView.CartView { product = q.name_product, image = q.name_image, price = q.price, quantity = 1, subtotal = (q.price * 1) }); Session["Cart"] = cart; } return(RedirectToAction("Cart")); }
public ActionResult create_update_customer() { var id = int.Parse(Request.Form["id_customer"]); var first_name = Request.Form["first_name"]; var last_name = Request.Form["last_name"]; var phone = Request.Form["phone"]; var email = Request.Form["email"]; var address = Request.Form["address"]; var password = Request.Form["password"]; Models.ModelView.CustomerView cv = new Models.ModelView.CustomerView(); cv.id = id; cv.first_name = first_name; cv.last_name = last_name; cv.phone = phone; cv.email = email; cv.address = address; cv.password = password; Models.IRepository <Models.ModelView.CustomerView> repository = Models.Dao.CustomerDao.Instance; repository.Update(cv); var q = repository.GetId(id); Session["inforCus"] = q; return(Json(q)); }
public ActionResult ProductDetail(int id) { Models.IRepository <Models.ModelView.ProductView> repository = Models.Dao.ProductDao.Instance; var q = repository.GetId(id); var q1 = repository.Gets(); ViewBag.listproduct = q; ViewBag.listproductall = q1; return(View()); }
public ActionResult Edit() { var id = int.Parse(Request.Form["id"]); Models.IRepository <Models.ModelView.ProductView> Product = Models.Dao.ProductDao.Instance; var q = Product.GetId(id); Session["EditProduct"] = q; return(RedirectToAction("Product")); }
public ActionResult EditProduct(int id) { /*var id = int.Parse(Request.Form["id"]);*/ Models.IRepository <Models.ModelView.ProductView> Product = Models.Dao.ProductDao.Instance; Session["inforProduct"] = Product.GetId(id); Models.IRepository <Models.ModelView.CategoryView> Category = Models.Dao.CategoryDao.Instance; Session["listCate"] = Category.Gets(); Models.IRepository <Models.ModelView.Brand> Brand = Models.Dao.BrandDao.Instance; Session["listBrand"] = Brand.Gets(); return(View()); }
public ActionResult DeleteProduct() { var id = int.Parse(Request.Form["id"]); Models.IRepository <Models.ModelView.ProductView> Product = Models.Dao.ProductDao.Instance; var q = Product.GetId(id); string fullPath = Request.MapPath("~/Areas/Admin/Upload/" + q.name_image); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } var result = Product.Delete(id); if (result == 1) { return(Json("success")); } else { return(Json("fail")); } }