public Task UpdateAsync(User user) { db.Users.Attach(user); db.Entry(user).State = EntityState.Modified; db.Configuration.ValidateOnSaveEnabled = false; return(db.SaveChangesAsync()); }
public ActionResult Edit([Bind(Include = "ID,Name")] Author author) { if (ModelState.IsValid) { db.Entry(author).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(author)); }
public ActionResult Edit([Bind(Include = "Id,Name")] Catergory catergory) { if (ModelState.IsValid) { db.Entry(catergory).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(catergory)); }
public void Update(Author item) { var entity = db.Authors.Find(item.Id); if (entity == null) { return; } db.Entry(entity).CurrentValues.SetValues(item); }
public ActionResult Edit([Bind(Include = "ID,Title,PublishedDate,Description,ISBN,CategotyID")] Book book) { if (ModelState.IsValid) { db.Entry(book).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CategotyID = new SelectList(db.Categories, "ID", "Name", book.CategotyID); return(View(book)); }
public void Update(Book item) { var entity = db.Books.Find(item.Id); if (entity == null) { return; } var tags = item.Tags; entity.Tags = new List <Tag>(); foreach (var booktag in tags) { Tag tag = db.Tags.SingleOrDefault(t => t.Name == booktag.Name); if (tag == null) { tag = new Tag { Name = booktag.Name }; db.Tags.Add(tag); } entity.Tags.Add(tag); } var authors = item.Authors; entity.Authors = new List <Author>(); foreach (var author in authors) { Author aut = db.Authors.SingleOrDefault(t => t.Name == author.Name); if (aut == null) { continue; } entity.Authors.Add(aut); } db.Entry(entity).CurrentValues.SetValues(item); }