コード例 #1
0
        public async Task <IActionResult> DeleteComment(int id)
        {
            // Deletes the comment and returns error if unsuccessful
            Result result = await _repository.DeleteUserCommentAsync(id);

            if (result.Failure)
            {
                return(StatusCode(result.Code, result.Error));
            }

            // Saves changes and return
            await _repository.SaveChangesAsync();

            return(Ok());
        }
コード例 #2
0
        public async Task <IActionResult> DeleteUserComment(int userCommentID)
        {
            // Deletes comment and returns error if access denied
            Result result = await _repository.DeleteUserCommentAsync(userCommentID);

            if (result.Failure)
            {
                return(Forbid());
            }

            await _repository.SaveChangesAsync();


            // Returns the view
            MessageViewModel model = new MessageViewModel()
            {
                Title        = "Comment deleted",
                MessageTitle = "Comment deleted"
            };

            return(View("Message", model));
        }