Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
 public ActionResult CreateSnippet()
 {
     var viewModel = new CreateSnippetVM();
     return View(viewModel);
 }