public async Task <IActionResult> SendAdminDeleteComment(int id, string reason) { // Deletes comment and saves changes await _repository.AdminDeleteCommentAsync(id, reason); await _repository.SaveChangesAsync(); // Returns view MessageViewModel model = new MessageViewModel() { Title = "Comment deleted", MessageTitle = "Comment deleted" }; return(View("Message", model)); }
public async Task <IActionResult> AdminDeleteComment(int id, AdminDeleteRequest request) { // Returns error if reason is null if (request.Reason == null) { return(BadRequest("Reason cannot be null")); } // Deletes the comment and returns 403 if unauthorised Result result = await _repository.AdminDeleteCommentAsync(id, request.Reason); if (result.Failure) { return(StatusCode(result.Code, result.Error)); } // Saves changes and returns await _repository.SaveChangesAsync(); return(Ok()); }