public async Task <IActionResult> DeleteComment([FromRoute] Guid activityId, [FromRoute] Guid commentId) { var(_, isFailure, comment, error) = await _commentsService.DeleteComment(activityId, commentId); if (isFailure) { return(BadRequest(error)); } return(Ok(comment)); }
public ActionResult DeleteComment(string commentId) { try { _commentsService.DeleteComment(commentId); return(NoContent()); } catch (NotFoundException ex) { return(NotFound(new AppError(ex.Message))); } }
public async Task DeleteNews(long id) { var comments = await _commentsService.GetCommenstsByNewsId(id); if (comments != null) { foreach (var c in comments) { _commentsService.DeleteComment(c.Id, c.Author.Id); } } _newsProvider.DeleteNewsDB(id); }
public async System.Threading.Tasks.Task DeleteComment([FromBody] CommentDTO comment) { string msg = "Your comment was deleted by moderator"; var com = await commentsService.GetComment(comment.Id); await notificationService.AddNotification(msg, com.UserId); await _hubContext.Clients.All.SendAsync("sendMessage", com.UserId, msg); await commentsService.DeleteComment(comment.Id); await Response.WriteAsync(JsonConvert.SerializeObject(comment, new JsonSerializerSettings { Formatting = Formatting.Indented })); }
public async Task <IActionResult> DeleteComment(long id) { Before(); var user = await _userManager.GetUserAsync(HttpContext.User); if (user == null) { return(RedirectToAction("SignIn", "Account")); } else { _commentService.DeleteComment(id, user.Id); return(RedirectToAction("UserProfile", "User")); } }
public ActionResult DeleteComment(int id) { string uid = User.Identity.GetUserId(); bool can = commentService.CanUserDeleteComment(uid, id); if (can) { commentService.DeleteComment(id); this.AddNotification("Komenti u fshi.", NotificationType.SUCCESS); } else { this.AddNotification("Ju nuk keni te drejte te fshini komentin.", NotificationType.ERROR); } return(RedirectToAction("Index")); }
public ActionResult DeleteComment(int id) { try { _commentsService.DeleteComment(id); } catch (FlowException ex) { return(BadRequest(ex.Message)); } catch (Exception) { return(StatusCode(500, "An error has occured!Try again later!")); } return(Ok()); }
public ActionResult DeleteComment(int commentId) { if (!ModelState.IsValid) { TempData["NotificationError"] = "Something get wrong. Try anaing later."; return(Redirect($"/Posts/Index")); } if (Request.IsAjaxRequest()) { var comment = m_Comments.GetById(commentId); m_Comments.DeleteComment(comment); return(Json(new { notification = "You successfully delete comment." })); } // Don't work in ajax!!! return(Redirect("/Posts/Index")); }
public ActionResult <MyResponse> DeleteComment(int id) { return(_commentsService.DeleteComment(id, GetUserId())); }
public async Task <IHttpActionResult> DeleteComment(int id) { var result = await service.DeleteComment(id); return(result != null?Ok(result) : GetErrorResult(false)); }
public async Task <IActionResult> DeleteComment([FromRoute] int id) { await _commentsService.DeleteComment(this.CurrentUserId.Value, id); return(this.Ok()); }
public Task Delete(int id) { return(_commentsService.DeleteComment(id)); }