Пример #1
0
        public async Task <IActionResult> RejectRoleRequest([FromBody] UpdateUserRoleRequestModel roleRequestModel)
        {
            try
            {
                var roleRequest = await _userRolesService.RejectRoleRequest(roleRequestModel);

                return(Ok(roleRequest));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Пример #2
0
        public async Task <UserRoleRequestResponseModel> RejectRoleRequest(UpdateUserRoleRequestModel roleRequestModel)
        {
            UserRoleRequest roleRequest = await _userRoleRequestsRepository.Get(roleRequestModel.Id);

            roleRequest.RoleId           = roleRequestModel.RoleId;
            roleRequest.UserId           = roleRequestModel.UserId;
            roleRequest.AcceptedByUserId = _userContext.GetUserId();
            roleRequest.AcceptationDate  = DateTime.UtcNow;
            roleRequest.Status           = UserRoleRequestStatus.Rejected;

            await _userRoleRequestsRepository.Save(roleRequest);

            await _userRolesManager.RemoveUserFromRole(roleRequestModel.UserId, roleRequestModel.RoleName);

            return(_mapper.Map <UserRoleRequestResponseModel>(roleRequest));
        }