public ActionResult Edit(Department updatedDepartment) { if (ModelState.IsValid) { db.Entry(updatedDepartment).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(updatedDepartment)); }
public ActionResult Edit(Product updateProduct) { //string _fileName = Path.GetFileNameWithoutExtension(updateProduct.FilePhoto.FileName); //string _extension = Path.GetExtension(updateProduct.FilePhoto.FileName); //_fileName = _fileName + DateTime.Now.ToString("yyMMddhhmmssfff") + _extension; //updateProduct.ImageUrl = _fileName; if (ModelState.IsValid) { string _fileName = Path.Combine(Server.MapPath("~/Uploads/ProductImages/") + TempData["product"].ToString()); updateProduct.ImageUrl = TempData["product"].ToString(); TempData.Remove("product"); if (updateProduct.FilePhoto != null) { updateProduct.FilePhoto.SaveAs(_fileName); } db.Entry(updateProduct).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(updateProduct)); }
public ActionResult Edit(Category updatedCatgory) { db.Entry(updatedCatgory).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }