コード例 #1
0
        public Response <bool> UpdateRoles(UpdateRolesModel model)
        {
            var request = new UpdateUserRolesRequest();

            request.UserId = model.UserId;
            request.Roles.AddRange(model.RoleIdList);

            var response = _client.UpdateUserRoles(request);

            return(response.Body);
        }
コード例 #2
0
        public ActionResult EditRoles(int clientId)
        {
            var roles  = this.userService.GetRoles().ToList();
            var client = this.clientsService.GetClient(clientId);
            var model  = new UpdateRolesModel
            {
                ClientId = client.Id,
                Roles    = client.Roles.Select(x => (Role)Enum.Parse(typeof(Role), roles.First(r => r.Id == x.RoleId).Name, true))
            };

            return(this.View(model));
        }
コード例 #3
0
        public ActionResult EditRoles(UpdateRolesModel model)
        {
            var roles  = this.userService.GetRoles();
            var client = this.clientsService.GetClient(model.ClientId);

            client.Roles.Clear();
            model.Roles.ForEach(
                r =>
            {
                var roleId = roles.First(x => x.Name == Enum.GetName(typeof(Role), r)).Id;
                client.Roles.Add(new IdentityUserRoleEntity
                {
                    RoleId = roleId,
                    UserId = client.Id
                });
            });
            this.clientsService.CreateOrUpdate(client);
            return(this.Json(true, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        public virtual ActionResult EditRoles(int userId)
        {
            var user  = membershipService.GetUser(userId);
            var model = new UpdateRolesModel
            {
                UserId = userId,
                Roles  = membershipService.GetRolesForUser(user.Id).Select(x => x.Id).ToArray()
            };

            var retult = new ControlFormResult <UpdateRolesModel>(model)
            {
                Title                = T("Update User Roles").Text,
                ShowBoxHeader        = false,
                FormWrapperStartHtml = Constants.Form.FormWrapperStartHtml,
                FormWrapperEndHtml   = Constants.Form.FormWrapperEndHtml
            };

            var roles = roleService.GetRecords().ToDictionary(k => k.Id, v => v.Name);

            retult.RegisterExternalDataSource(x => x.Roles, roles);

            return(retult);
        }
コード例 #5
0
 public ActionResult EditRoles(UpdateRolesModel model)
 {
     membershipService.AssignUserToRoles(model.UserId, model.Roles);
     return(new AjaxResult().CloseModalDialog());
 }