public ActionResult CreateSnippet(CreateSnippetVM vm) { if (ModelState.IsValid) { Snippet snippet = new Snippet { Title = vm.Title, Content = vm.Content, DatePublished = DateTime.Now }; if (webSecurity.IsAuthenticated) { snippet.UserId = webSecurity.CurrentUserId; } this.snippetRepo.Add(snippet); return RedirectToAction("Show", new { id = snippet.Id }); } else { return View(); } }
public ActionResult CreateSnippet() { var viewModel = new CreateSnippetVM(); return View(viewModel); }