Example #1
0
        public ActionResult ApprovePost([FromQuery] int postId)
        {
            var result = _postRepository.ApprovePost(postId);

            if (result.IsError)
            {
                return(BadRequest(result.Message));
            }

            return(Ok());
        }
Example #2
0
        public object Approve(int id)
        {
            try
            {
                var post = _postRepository.GetById(id);

                if (post == null)
                {
                    throw new Exception("Post no found.");
                }

                _postRepository.ApprovePost(id);
                return(new { message = "Post Approved." });
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = "Error approving post.", error = ex.Message }));
            }
        }
Example #3
0
        public IActionResult ApprovePost(int id)
        {
            _postRepository.ApprovePost(id);

            return(RedirectToAction("AdminView", "Posts"));
        }