Exemple #1
0
        public JsonResult Delete(int postID)
        {
            VerifyOwnership(postID);

            if (postID > 0)
            {
                _postRepository.DeletePost(postID);
            }
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
        public JsonResult Delete(int postID)
        {
            ValidateActionRequest("An unauthorized access was detected");

            if (postID > 0)
            {
                _postRepository.DeletePost(postID);
            }
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
        public async Task <IActionResult> ConfirmDelete(int id)
        {
            var post = _postService.GetById(id);

            if (post.Replies.Any())
            {
                foreach (var reply in post.Replies.ToList())
                {
                    if (System.IO.File.Exists(_environment.WebRootPath + reply.ImageUrl))
                    {
                        System.IO.File.Delete(_environment.WebRootPath + reply.ImageUrl);
                    }
                    await _userService.DecrementUserRating(reply.User.Id, typeof(PostReply));

                    await _postService.DeleteReply(reply.Id);
                }
            }
            if (System.IO.File.Exists(_environment.WebRootPath + post.ImageUrl))
            {
                System.IO.File.Delete(_environment.WebRootPath + post.ImageUrl);
            }
            await _userService.DecrementUserRating(post.User.Id, typeof(Post));

            await _postService.DeletePost(post.Id);

            return(RedirectToAction("Index", "Forum", new { id = post.Forum.Id }));
        }
        public async Task <IActionResult> ConfirmDelete(int id)
        {
            var post = _postService.GetPostById(id);
            await _postService.ClearReplies(id);

            await _postService.DeletePost(id);

            return(RedirectToAction("Index", "Forum", new { id = post.Forum.Id }));
        }
Exemple #5
0
        public IActionResult DeletePost(uint id, string username)
        {
            if (_postService.DeletePost(id, username))
            {
                return(Ok());
            }

            return(NotFound());
        }
        public IActionResult Delete(int postId)
        {
            var deletePost = _postRepository.DeletePost(postId);

            if (deletePost != null)
            {
                TempData["message"] = $"{deletePost.NamePost} was deleted.";
            }

            return(RedirectToAction("List"));
        }
 public IActionResult DeletePost(int id)
 {
     try
     {
         ipost.DeletePost(id);
         return(Ok(HttpStatusCode.OK));
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
        public IActionResult Delete(int postID)
        {
            Post deletedPost = repository.DeletePost(postID);

            if (deletedPost != null)
            {
                TempData["message"] = $"{ deletedPost.Title} was deleted";
            }
            else
            {
                TempData["message"] = $"{ deletedPost.Title} was'nt deleted";
            }

            return(RedirectToAction("Index"));
        }
        public IActionResult Delete(int id)
        {
            var post = _posts.GetById(id);

            if (_posts.DeletePost(post))
            {
                if (post.PostType == PostType.Issue)
                {
                    return(RedirectToAction("Issues"));
                }
                else
                {
                    return(RedirectToAction("Events"));
                }
            }

            return(BadRequest());
        }
Exemple #10
0
        public async Task <ActionResult <Response> > DeletePost()
        {
            try
            {
                int  id     = Convert.ToInt32(Request.Form["id"][0]);
                bool result = await post_.DeletePost(id);

                if (result)
                {
                    response.Message   = "Post eliminado";
                    response.MessageId = 2;
                    response.Status    = true;
                    response.Object    = null;
                }
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                response.Status  = false;
                response.Object  = null;
            }
            return(response);
        }
Exemple #11
0
        /// <summary>
        /// 删除文章
        /// </summary>
        /// <param name="postid"></param>
        /// <returns></returns>
        public static int DeletePost(int postid)
        {
            PostInfo oldPost = GetPost(postid);

            _posts.Remove(oldPost);

            int result = dao.DeletePost(postid);

            //统计
            StatisticsManager.UpdateStatisticsPostCount(-1);
            //用户
            UserManager.UpdateUserPostCount(oldPost.UserId, -1);
            //分类
            CategoryManager.UpdateCategoryCount(oldPost.CategoryId, -1);
            //标签
            TagManager.UpdateTagUseCount(oldPost.Tag, -1);

            //删除所有评论
            CommentManager.DeleteCommentByPost(postid);

            //     RemovePostsCache();

            return(result);
        }
Exemple #12
0
 public static void DeletePost(int Id)
 {
     dal.DeletePost(Id);
     CacheHelper.Remove(cacheKey);
     CacheHelper.Remove(postCourseCacheKey);
 }
 public IHttpActionResult Delete(int id)
 {
     _adapter.DeletePost(id);
     return Ok();
 }
        /// <summary>
        /// This method deletes a post and redirects to the index page
        /// </summary>
        /// <returns>A redirect to the index page</returns>
        public async Task <IActionResult> OnPostDelete()
        {
            await _post.DeletePost(ID);

            return(RedirectToPage("/Index"));
        }
Exemple #15
0
 public void DeletePost()
 {
     postrepository.DeletePost(Id);
 }