public ActionResult Edit([Bind(Include = "ID,Name,Description,Components,CategoryID,ProfileID,TypeID")] Recipe recipe) { HttpPostedFileBase file = Request.Files["fileWithPicture"]; if (file != null && file.ContentLength > 0) { recipe.Picture = System.Guid.NewGuid().ToString(); recipe.Picture = file.FileName; file.SaveAs(HttpContext.Server.MapPath("~/Pictures/") + recipe.Picture); } if (ModelState.IsValid) { db.Entry(recipe).State = EntityState.Modified; if (file == null || file.ContentLength == 0) { db.Entry(recipe).Property(p => p.Picture).IsModified = false; } db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategoryID = new SelectList(db.Categories, "ID", "Name", recipe.CategoryID); ViewBag.ProfileID = new SelectList(db.Profiles, "ID", "Login", recipe.ProfileID); ViewBag.TypeID = new SelectList(db.Types, "ID", "Name", recipe.TypeID); return(View(recipe)); }
public ActionResult Edit([Bind(Include = "ID,Login,FirstName,LastName,Age,IsMale")] Profile profile) { if (ModelState.IsValid) { db.Entry(profile).State = EntityState.Modified; db.SaveChanges(); } return(View(profile)); }
public ActionResult Edit([Bind(Include = "ID,Name")] Models.Type type) { if (ModelState.IsValid) { db.Entry(type).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(type)); }
public ActionResult Edit([Bind(Include = "ID,Rate,RecipeID,ProfileID")] Rating rating) { if (ModelState.IsValid) { db.Entry(rating).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProfileID = new SelectList(db.Profiles, "ID", "Login", rating.ProfileID); ViewBag.RecipeID = new SelectList(db.Recipes, "ID", "Name", rating.RecipeID); return(View(rating)); }
public ActionResult Edit([Bind(Include = "ID,Content,CommentDate,RecipeID,ProfileID")] Comment comment) { if (ModelState.IsValid) { db.Entry(comment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProfileID = new SelectList(db.Profiles, "ID", "Login", comment.ProfileID); ViewBag.RecipeID = new SelectList(db.Recipes, "ID", "Name", comment.RecipeID); return(View(comment)); }