Esempio n. 1
0
 public ActionResult Create()
 {
     CheckPermission();
     var model = new CreateRoleModel();
     model.BelongsArray = _belongsSystemService.GetSystems();
     return View(model);
 }
Esempio n. 2
0
 public ActionResult Create(CreateRoleModel model)
 {
     CheckPermission();
     if (ModelState.IsValid)
     {
         if (_roleService.ExistsRole(model.Name))
         {
             ModelState.AddModelError("Name", string.Format("角色名 {0} 已经存在", model.Name));
             return View(model);
         }
         Role newRole = new Role
         {
             Name = model.Name,
             Description = model.Description,
             Category = model.Category,
             BelongsTo = model.BelongsTo,
             Enabled = true
         };
         _roleService.AddRole(newRole);
         return RedirectToAction("Edit", new { id = newRole.Id });
     }
     model.BelongsArray = _belongsSystemService.GetSystems();
     return View(model);
 }