Exemplo n.º 1
0
 //
 // GET: /Posts/New
 public ActionResult New()
 {
     PostViewModel viewModel = new PostViewModel
     {
         ExistingTags = _tagsRepository.GetAll()
     };
     return View(viewModel);
 }
Exemplo n.º 2
0
        public ActionResult New(PostViewModel view)
        {
            if (ModelState.IsValid)
            {
                Post post = new Post
                {
                    Title = view.Title,
                    Message = view.Message,
                    PostedBy = User.ID
                };

                _postsRepository.Create(post);
                return RedirectToAction("Index");
            }

            return View(view);
        }