public ActionResult Edit([Bind(Include = "UserID,UserName,Email,Adress,City,ZipCode")] Users users) { //If email is changed, verify that it is not already in use //Update own database then identity database dbMSA3Entities cont = new dbMSA3Entities(); List <Users> userlist = new List <Users>(); ViewBag.ErrorMsg = ""; userlist = db.Users.SqlQuery("Select * from Users where Users.Email ='" + users.Email + "' AND NOT (Users.UserID = '" + users.UserID + "')").ToList(); if (userlist.Count > 0) { ViewBag.ErrorMsg = "The Email is already in use"; return(View()); } //Update own database table Users try { db.Users.SqlQuery("Update Users SET Email = '" + users.Email + "',UserName = '******',Adress = '" + users.Adress + "',City = '" + users.City + "',ZipCode = '" + users.ZipCode + "' WHERE Users.UserID = '" + users.UserID + "'"); db.SaveChanges(); } catch (Exception e) { ViewBag.ErrorMsg = "Unable to update database. Errormessage:" + e.Message.ToString(); return(View()); } //Update the identity database if (ModelState.IsValid) { db.Entry(users).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(users)); }
public ActionResult Edit([Bind(Include = "CategoryID,CategoryName")] Categories categories) { if (ModelState.IsValid) { db.Entry(categories).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(categories)); }
public ActionResult Edit([Bind(Include = "ProductID,ProductName,MovieDescription,Price,NrInStore,Rating,ProductTypeID")] Products products) { if (ModelState.IsValid) { db.Entry(products).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductTypeID = new SelectList(db.ProductType, "ProductTypeID", "ProductTypeName", products.ProductTypeID); return(View(products)); }
public ActionResult Edit([Bind(Include = "OrderID,UserID,OrderSent,OrderSentDate,OrderDateTime")] Orders orders) { if (ModelState.IsValid) { db.Entry(orders).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserID = new SelectList(db.Users, "UserID", "UserName", orders.UserID); return(View(orders)); }
public ActionResult Edit([Bind(Include = "ProdCatID,ProductID,CategoryID")] ProdCat prodCat) { if (ModelState.IsValid) { db.Entry(prodCat).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", prodCat.CategoryID); ViewBag.ProductID = new SelectList(db.Products, "ProductID", "ProductName", prodCat.ProductID); return(View(prodCat)); }