Exemplo n.º 1
0
        public async Task <ActionResult> AddComment(int?id, string value)
        {
            Case @case = await Database.Cases.FindAsync(id);

            if (!HttpContext.CheckAccess(UhomeResources.Actions.View, UhomeResources.Case, id.ToString()))
            {
                throw new Exception(Resources.Resources.PermissionDenied);
            }

            var commentViewModel = @case.AddComment(value, CurrentUser);

            @case.UpdatedAt = System.DateTime.Now;
            await Database.SaveChangesAsync();

            return(Json(new { newCommentRow = this.RenderPartialViewToString("_EditCommentPartial", commentViewModel) }));
        }