Пример #1
0
        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));
        }
Пример #2
0
 public ActionResult DeleteComment(string commentId)
 {
     try
     {
         _commentsService.DeleteComment(commentId);
         return(NoContent());
     }
     catch (NotFoundException ex)
     {
         return(NotFound(new AppError(ex.Message)));
     }
 }
Пример #3
0
        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);
        }
Пример #4
0
        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
            }));
        }
Пример #5
0
        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"));
            }
        }
Пример #6
0
        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"));
        }
Пример #7
0
        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());
        }
Пример #8
0
        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"));
        }
Пример #9
0
 public ActionResult <MyResponse> DeleteComment(int id)
 {
     return(_commentsService.DeleteComment(id, GetUserId()));
 }
Пример #10
0
        public async Task <IHttpActionResult> DeleteComment(int id)
        {
            var result = await service.DeleteComment(id);

            return(result != null?Ok(result) : GetErrorResult(false));
        }
Пример #11
0
        public async Task <IActionResult> DeleteComment([FromRoute] int id)
        {
            await _commentsService.DeleteComment(this.CurrentUserId.Value, id);

            return(this.Ok());
        }
Пример #12
0
 public Task Delete(int id)
 {
     return(_commentsService.DeleteComment(id));
 }