示例#1
0
        // GET: PostTagController/Delete/5
        public ActionResult Delete(int id)
        {
            {
                IEnumerable <PostTag> postTags = _postTagRepository.GetAllPostTagsByPostId(id);

                List <int> postTagsSelected = new List <int>();
                Post       post             = _postRepository.GetPublishedPostById(id);

                //creating an instance of the view model class
                PostTagFormViewModel vm = new PostTagFormViewModel()
                {
                    PostTag          = new PostTag(),
                    PostTagsSelected = postTagsSelected,
                    PostId           = id,
                    PostTags         = postTags
                };
                if (post.UserProfileId == int.Parse(User.Claims.ElementAt(0).Value))
                {
                    return(View(vm));
                }
                else
                {
                    return(NotFound());
                }
            }
        }
示例#2
0
        public IActionResult GetAllPostTagsByPostId(int postId)
        {
            var tags = _postTagRepository.GetAllPostTagsByPostId(postId);

            if (tags == null)
            {
                return(NotFound());
            }
            return(Ok(tags));
        }
示例#3
0
        public IActionResult Details(int id)
        {
            var post = new Post();

            post = _postRepository.GetPublishedPostById(id);

            if (post == null)
            {
                return(NotFound());
            }
            else
            {
                post.TagNames = _postTagRepository.GetAllPostTagsByPostId(id);
                return(View(post));
            }
        }
 public IActionResult GetAllPostTagsByPost(int id)
 {
     return(Ok(_postTagRepository.GetAllPostTagsByPostId(id)));
 }