Exemplo n.º 1
0
        public ActionResult Create(PostViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                repository.AddNewPost(viewModel.Post);
                string action = "../Post/Index/" + viewModel.Post.BlogID.ToString();
                return RedirectToAction(action);
            }

            return View(viewModel);
        }
Exemplo n.º 2
0
        public ActionResult Create(int id)
        {
            Blog blog = repository.GetBlogByID(id);
            List<Post> posts = repository.GetPostsByBlogID(id);
            Blogger blogger = repository.GetBloggerByID(blog.BloggerID);

            Post newPost = new Post();
            newPost.BlogID = blog.BlogID;
            newPost.DateCreated = DateTime.Now;

            PostViewModel viewModel = new PostViewModel(blog, blogger, newPost, posts);
            return View(viewModel);
        }
Exemplo n.º 3
0
 public ActionResult Index(int id)
 {
     List<Post> posts = repository.GetPostsByBlogID(id);
     Blog blog = repository.GetBlogByID(id);
     Blogger blogger = repository.GetBloggerByID(blog.BloggerID);
     PostViewModel viewModel = new PostViewModel(blog, blogger, null, posts);
     return View(viewModel);
 }