public bool EditComment(CommentEditRAO rao) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Comments .Single(c => c.CommentId == rao.CommentId && c.OwnerId == _userId); entity.Content = rao.Content; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(CommentEditDTO dto) { var svc = GetCommentService(); var rao = new CommentEditRAO { CommentId = dto.CommentId, Content = dto.Content, GroupId = dto.GroupId }; if (svc.EditComment(rao)) { return(RedirectToAction("Index", "Group", new { id = dto.GroupId })); } else { return(RedirectToAction("Index", "Group", new { id = dto.GroupId })); } }