Guest User

Untitled

a guest
Apr 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. public IEnumerable<MvcInternetShop.Models.DomainModels.Group> Groups { get; set; }
  2. public MvcInternetShop.Models.DomainModels.Group Group { get; set; }
  3.  
  4. public ActionResult AddGroup(Group model)
  5. {
  6.  
  7. if (ModelState.IsValid)
  8. {
  9.  
  10.  
  11. if (gr.Add(model)) // gr is a GroupRepository for CRUD.
  12. return JavaScript("notif({type: 'info',msg: 'Your Group Registerd.',width: 'all',height: 100,position: 'center'});");
  13. else
  14. return JavaScript("notif({type: 'error',msg: 'Error.Try again!.',width: 'all',height: 100,position: 'center'});");
  15.  
  16. }
  17. else
  18. {
  19. return JavaScript("notif({type: 'error',msg: '" + ModelState.GetErrors() + "',width: 'all',height: 100,position: 'center',modal:true});");//GetError() is a myExtension method.
  20. }
  21. }
  22.  
  23. @using (Ajax.BeginForm("AddGroup", "Admin", new AjaxOptions { HttpMethod="Post",Url="/Admin/AddGroup"}))
  24. {
  25. @Html.TextBoxFor(p=>Model.Group.Name)//Model is a viewmodel that contains Group and Groups property.
  26. @Html.ValidationMessageFor(p => Model.Group.Name)
  27. <button type="submit" class="button">Add group</button>}
Add Comment
Please, Sign In to add comment