Guest User

Untitled

a guest
Jan 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. <button class="button" data-open="categoryModal">Create A Group</button>
  2.  
  3. <div class="reveal" id="categoryModal" data-reveal>
  4. <h1>Create Category</h1>
  5. @using (Html.BeginForm("CreateCategory", "Home"))
  6. {
  7. <input type="text" name="categoryName" />
  8. <input type="submit" class="button"/>
  9. }
  10. </div>
  11.  
  12. [HttpPost]
  13. public IActionResult CreateCategory(CategoryVM category)
  14. {
  15. if(!ModelState.IsValid) return View(category);
  16.  
  17. if (//category already exists)
  18. {
  19. ModelState.AddModelError("", "Category exists");
  20. return View(category);
  21. }
  22. _categoryRepository.Insert(new Category { Name = category.Name });
  23. return RedirectToAction("Index", "Home");
  24. }
Add Comment
Please, Sign In to add comment