public ActionResult Edit([Bind(Include = "Id,Body,CreateTime,BlogId,PosterId")] Comment comment) { if (ModelState.IsValid) { db.Entry(comment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BlogId = new SelectList(db.Blogs, "Id", "Title", comment.BlogId); ViewBag.PosterId = new SelectList(db.Users, "Id", "UserName", comment.PosterId); return(View(comment)); }
public async Task <bool> EditPostAsync(EditPostViewModel post, string authorId) { var model = _mapper.Map <Post>(post); model.AuthorId = authorId; var entity = await _context.Posts.FindAsync(model.Id); _context.Entry(entity).CurrentValues.SetValues(model); var success = await _context.SaveChangesAsync() > 0; if (success) { return(true); } return(false); }
public void Update(Category entity) { _context.Categories.Attach(entity); _context.Entry(entity).State = EntityState.Modified; }
public void Update(T entity) { _dbSet.Attach(entity); _context.Entry(entity).State = EntityState.Modified; }