예제 #1
0
        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);
            }
        }
예제 #2
0
        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 }));
            }
        }