//public ActionResult Add()
        public ActionResult Add()
        {
            var viewModel = new PostAddViewModel();

            viewModel.Init(_tagRepository, _categoryRepository);

            return(View(viewModel));
        }
        public ActionResult Add(PostAddViewModel viewModel)
        {
            ValidatePost(viewModel.Post);

            if (ModelState.IsValid)
            {
                var post = viewModel.Post;

                _postRepository.Add(post);
                _postTagsRepository.Add(new PostTags {
                    PostId = post.Id, TagId = viewModel.TagId
                });

                TempData["Message"] = "Your post was successfully added.";

                return(RedirectToAction("Details", new { id = post.Id }));
            }


            viewModel.Init(_tagRepository, _categoryRepository);

            return(View(viewModel));
        }