Exemple #1
0
 public ActionResult AddPrivilege(RolePrivilegeViewModel model)
 {
     if (ModelState.IsValid)
     {
         var request = model.MapTo<SaveRolePrivilegeRequest>();
         request.UserId = this.UserProfile().UserId;
         var result = _rolePrivilegeService.SaveRolePrivilege(request);
         return Json(result);
     }
     else
     {
         var errorList = (from item in ModelState
                          where item.Value.Errors.Any()
                          select item.Value.Errors[0].ErrorMessage).ToList();
         return Json(new { IsSuccess = false, Message = errorList });
     }
     //ViewBag.RoleGroups = _roleGroupService.GetRoleGroups(new Services.Requests.RoleGroup.GetRoleGroupsRequest
     //{
     //    Take = -1,
     //    SortingDictionary = new Dictionary<string, SortOrder> { { "Name", SortOrder.Ascending } }
     //})
     //                .RoleGroups.Select(x => new SelectListItem
     //                {
     //                    Text = x.Name,
     //                    Value = x.Id.ToString(),
     //                    Selected = model.RoleGroup_Id == x.Id
     //                }).ToList();
     //return View(model);
 }
Exemple #2
0
        public ActionResult Create(RolePrivilegeViewModel model)
        {
            if (ModelState.IsValid)
            {
                var request = model.MapTo<SaveRolePrivilegeRequest>();
                request.UserId = this.UserProfile().UserId;
                if (_roleService.SaveRolePrivilege(request).IsSuccess)
                {
                    return RedirectToAction("Index", new { roleId = request.RoleGroup_Id });
                }

            }
            ViewBag.RoleGroups = _roleGroupService.GetRoleGroups(new Services.Requests.RoleGroup.GetRoleGroupsRequest
            {
                Take = -1,
                SortingDictionary = new Dictionary<string, SortOrder> { { "Name", SortOrder.Ascending } }
            })
                            .RoleGroups.Select(x => new SelectListItem
                            {
                                Text = x.Name,
                                Value = x.Id.ToString(),
                                Selected = model.RoleGroup_Id == x.Id
                            }).ToList();

            return View(model);
        }