public ActionResult Create([Bind(Include = "ID,Name,Categories,Quantity,Price,Picture,Description")] Product product) { if (ModelState.IsValid) { db.Products.Add(product); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Categories = new SelectList(db.Categories, "ID", "CategoriesName", product.Categories); return(View(product)); }
public ActionResult Create([Bind(Include = "ID,LoginId,Password,FirstName,LastName,Address,Gender,Phonenumber,UserRole")] tblUser tblUser) { if (ModelState.IsValid) { db.tblUsers.Add(tblUser); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserRole = new SelectList(db.tblRoles, "ID", "UserRole", tblUser.UserRole); return(View(tblUser)); }
public ActionResult AddItemsToCart(int productid) { using (RHASTOREEntities db = new RHASTOREEntities()) { if (User.Identity.Name == "") { return(RedirectToAction("Login", "Account")); } else { var currentuser_id = Convert.ToInt32(User.Identity.Name);//this is actually the unique user id,the name is misleading var product_id = productid; var quantity = 1; Cart c = new Cart(); c.userid = currentuser_id; c.ProductId = product_id; c.Quantity = quantity; db.Carts.Add(c); db.SaveChanges(); } return(RedirectToAction("Index")); } }
public ActionResult DeleteConfirmed(int id) { Cart product = db.Carts.Find(id); db.Carts.Remove(product); db.SaveChanges(); return(RedirectToAction("Index")); }