public ActionResult Edit([Bind(Include = "Id,Name,Description")] Event @event) { if (ModelState.IsValid) { db.Entry(@event).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(@event)); }
public ActionResult Edit([Bind(Include = "Id,Name,Surname")] Author author) { if (ModelState.IsValid) { db.Entry(author).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(author)); }
public ActionResult Edit(Author author, int[] writtenEvents) { Author newAuthor = db.Authors.Find(author.Id); newAuthor.Name = author.Name; newAuthor.Surname = author.Surname; newAuthor.Events.Clear(); if (writtenEvents != null) { //получаем написанные события foreach (var c in db.Events.Where(co => writtenEvents.Contains(co.Id))) { newAuthor.Events.Add(c); } } db.Entry(newAuthor).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
//[ValidateAntiForgeryToken] public ActionResult Edit(Author author) { if (ModelState.IsValid) { foreach (Book book in author.Books) { if (book.Id == -1) { db.Books.Add(book); } } db.Entry(author).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(author)); }