예제 #1
0
 public bool DeletePost([FromBody] PostOptions postOptions)
 {
     if (postOptions != null)
     {
         return(_postservices.DeletePost(postOptions.PostId));
     }
     return(false);
 }
예제 #2
0
 public IActionResult Delete(long id)
 {
     if (!_postServices.DeletePost(id))
     {
         return(NotFound());
     }
     return(NoContent());
 }
예제 #3
0
        public async Task <IActionResult> Delete(int id)
        {
            var result = await postServices.DeletePost(id);

            var response = new ApiResponse <bool>(result);

            return(Ok(response));
        }
예제 #4
0
        public async Task <IActionResult> DeleteConfirmed(int id,
                                                          [FromServices] IPostCategoryServices postcategoryServices,
                                                          [FromServices] ICommentServices commentServices)
        {
            await postServices.DeletePost(id);

            //two steps underneath not necessary Entity frameworks allready solves it, but it was a good exercise ;-)
            await DeleteExistingPostCategoryEntries(id, postcategoryServices);
            await DeleteExistingPostCommentEntries(id, commentServices);


            return(RedirectToAction("Index"));
        }
예제 #5
0
        public IActionResult DeletePost([FromBody] DeletePostRequest request)
        {
            try
            {
                if (request == null)
                {
                    return(BadRequest(new ErrorViewModel
                    {
                        ErrorCode = "400",
                        ErrorMessage = "Please provide input information correctly."
                    }));
                }

                if (request.PostId <= 0)
                {
                    return(BadRequest(new ErrorViewModel
                    {
                        ErrorCode = "400",
                        ErrorMessage = "Post not found"
                    }));
                }

                var Post = _postRepository.FindById(request.PostId);
                if (Post == null)
                {
                    return(BadRequest(new ErrorViewModel
                    {
                        ErrorCode = "400",
                        ErrorMessage = "Post not found"
                    }));
                }

                var response = _postServices.DeletePost(Post);
                if (response != "OK")
                {
                    return(BadRequest("Can not execute. Plz contact admin"));
                }
                return(Ok(response));
            }
            catch (Exception e)
            {
                return(BadRequest(new ErrorViewModel
                {
                    ErrorCode = "400",
                    ErrorMessage = $"Server Error: {e.Message}"
                }));
            }
        }
예제 #6
0
        public async Task <IActionResult> Delete([FromRoute] int postId)
        {
            if (!(postId > 0))
            {
                return(BadRequest("Post Id is Empty"));
            }

            var isDeleted = await _postServices.DeletePost(postId);

            if (isDeleted)
            {
                return(NoContent());
            }

            return(NotFound());
        }
예제 #7
0
 public IActionResult DeletePost(string id)
 {
     postServices.DeletePost(id, User);
     return(RedirectToAction("SuccessfullAction", "Profiles", new { message = ControllerConstants.SuccessfullyDeletedPostMessage }));
 }