public ActionResult Edit([Bind(Include = "MovieID, Name, YearOfRelease, Plot, Title, ImagePath")] MovieActorProducerImageVM mapiVM) { if (ModelState.IsValid) { db.Entry(mapiVM).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(mapiVM)); }
public ActionResult Edit([Bind(Include = "Name, Sex, DOB, Bio")] Producer producer) { if (ModelState.IsValid) { //db.Entry(producer).State = EntityState.Modified; db.Entry(producer).State = EntityState.Added;//Primary key value cant be modified so instead we create a new Row by Added db.SaveChanges(); return(RedirectToAction("Index")); } return(View(producer)); }
public ActionResult Edit([Bind(Include = "Name, Sex, DOB, Bio")] Actor actor) { if (ModelState.IsValid) { db.Actors.Where(x => x.ActorID == actor.ActorID).SingleOrDefault(); //db.Entry(actor).State = EntityState.Modified; db.Entry(actor).State = EntityState.Added; //Primary key value cant be modified so instead we create a new Row by Added db.SaveChanges(); return(RedirectToAction("Index")); } return(View(actor)); }
public ActionResult Edit([Bind(Include = "MovieID, Name, YearOfRelease, Plot, Poster, ActorID, ProducerID")] Movy movy, HttpPostedFileBase file) { string pic = null; if (file != null) { pic = System.IO.Path.GetFileName(file.FileName); string Path = System.IO.Path.Combine(Server.MapPath("~/Images/"), pic); file.SaveAs(Path); movy.Poster = file != null ? pic : movy.Poster; } if (ModelState.IsValid) { db.Entry(movy).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(movy)); }