public ActionResult OrderNow(Table_products model) { string size = db.Table_Size.Where(s => s.s_id == model.s_id).Select(a => a.s_size).Single(); string color = db.Table_Colors.Where(s => s.c_id == model.c_id).Select(a => a.c_name).Single(); if (Session["cart"] == null) { List <Item> cart = new List <Item>(); cart.Add(new Item(model, 1, size, color)); Session["cart"] = cart; } else { List <Item> cart = (List <Item>)Session["cart"]; int index = -1; index = isExisting((int)model.p_id, size, color); if (index == -1) { cart.Add(new Item(model, 1, size, color)); } else { cart[index].Quantity++; } Session["cart"] = cart; } ViewBag.category_id = new SelectList(db.Table_Category, "category_id", "category_name", model.category_id); ViewBag.c_id = new SelectList(db.Table_Colors, "c_id", "c_name", model.c_id); ViewBag.s_id = new SelectList(db.Table_Size, "s_id", "s_size", model.s_id); ViewBag.add = "add"; return(RedirectToAction("ViewCart")); }
public Item(Table_products p, int q, string s, string c) { products = p; quantity = q; size = s; color = c; }
public ActionResult products_detail(int?id, int?val) { Table_products table_products = db.Table_products.Where(m => m.p_id == id).Single(); ViewBag.c_id = new SelectList(db.Table_Colors.Where(m => m.category_id == val), "c_id", "c_name", table_products.c_id); ViewBag.s_id = new SelectList(db.Table_Size.Where(m => m.category_id == val), "s_id", "s_size", table_products.s_id); return(View(table_products)); }
public ActionResult DeleteConfirmed(int id) { Table_products table_products = db.Table_products.Find(id); db.Table_products.Remove(table_products); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: /products/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Table_products table_products = db.Table_products.Find(id); if (table_products == null) { return(HttpNotFound()); } return(View(table_products)); }
// GET: /products/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Table_products table_products = db.Table_products.Find(id); if (table_products == null) { return(HttpNotFound()); } ViewBag.category_id = new SelectList(db.Table_Category, "category_id", "category_name", table_products.category_id); ViewBag.c_id = new SelectList(db.Table_Colors, "c_id", "c_name", table_products.c_id); ViewBag.s_id = new SelectList(db.Table_Size, "s_id", "s_size", table_products.s_id); return(View(table_products)); }
public ActionResult Create(Table_products table_products) { if (ModelState.IsValid) { String fileName = Path.GetFileNameWithoutExtension(table_products.ImageFile.FileName); String extension = Path.GetExtension(table_products.ImageFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; table_products.p_img = "~/Images/" + fileName; fileName = Path.Combine(Server.MapPath("~/Images/"), fileName); table_products.ImageFile.SaveAs(fileName); db.Table_products.Add(table_products); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.category_id = new SelectList(db.Table_Category, "category_id", "category_name", table_products.category_id); ViewBag.c_id = new SelectList(db.Table_Colors, "c_id", "c_name", table_products.c_id); ViewBag.s_id = new SelectList(db.Table_Size, "s_id", "s_size", table_products.s_id); return(View(table_products)); }