Esempio n. 1
0
        public ActionResult Update(Guid id, RolesUpdateModel model)
        {
            UpdateRoleRequest request = new UpdateRoleRequest
            {
                RolesUpdateModel = model,
                Id = id
            };
            UpdateRoleResponse response = _roleService.UpdateRole(request);

            if (response.HasError)
            {
                return(HttpNotFound());
            }
            return(RedirectToAction("update", new { id = id }).AndAlert(AlertType.Success, "Success.",
                                                                        "Role updated successfully."));
        }
Esempio n. 2
0
        public void T02_RolesModifications()
        {
            var rolesUpdateModel = new RolesUpdateModel
            {
                Name     = "CustomRole",
                UserType = UserType.SystemUser
            };

            var role = new AddRoleRequest
            {
                Customer         = _customer,
                RolesUpdateModel = rolesUpdateModel
            };

            _roleService.AddRole(role);

            var roleSummury = _roleService.RolesList(_customer.Id).Roles.FirstOrDefault(t => t.Name == "CustomRole");

            Assert.IsNotNull(roleSummury, "Can not add role");

            var roleResponse = _roleService.Get(new GetRoleRequest {
                Id = roleSummury.Id
            });

            rolesUpdateModel.Name = "CustomRoleReName";
            _roleService.UpdateRole(new UpdateRoleRequest
            {
                Id = roleResponse.RolesUpdateModel.Id,
                RolesUpdateModel = rolesUpdateModel
            });

            roleSummury = _roleService.RolesList(_customer.Id).Roles.FirstOrDefault(t => t.Name == "CustomRoleReName");
            Assert.IsNotNull(roleSummury, "Can not edit role");

            _roleService.DeleteRole(new DeleteRoleRequest {
                Id = roleSummury.Id
            });
            roleSummury = _roleService.RolesList(_customer.Id).Roles.FirstOrDefault(t => t.Name == "CustomRoleReName");
            Assert.IsNull(roleSummury, "Can not delete role");
        }