Ejemplo n.º 1
0
        public JsonResult Delete(System.Int32 id)
        {
            RemoveRoleRequest request = new RemoveRoleRequest();

            request.RoleId = id;
            RemoveRoleResponse response = _roleService.RemoveRole(request);

            return(Json(response));
        }
Ejemplo n.º 2
0
    /// <summary>
    /// Remove Role Async.
    /// </summary>
    /// <param name="request">The <see cref="RemoveRoleRequest{TIdentity}"/>.</param>
    /// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param>
    /// <returns>Void.</returns>
    public virtual async Task RemoveUserRoleAsync(RemoveRoleRequest <TIdentity> request, CancellationToken cancellationToken = default)
    {
        if (request == null)
        {
            throw new ArgumentNullException(nameof(request));
        }

        request.Controller = BaseIdentityApi <TUser, TIdentity> .IdentityController;

        await this.InvokeAsync(request, cancellationToken);
    }
Ejemplo n.º 3
0
        public RemoveRoleResponse RemoveRole(RemoveRoleRequest request)
        {
            RemoveRoleResponse response = new RemoveRoleResponse();

            response.Errors = new List <BusinessRule>();
            try {
                if (_roleRepository.Remove(request.RoleId) > 0)
                {
                    response.RoleDeleted = true;
                }
            } catch (Exception ex)
            {
                response.Errors.Add(new BusinessRule("DAL", "DAL_ERROR: " + ex.Message));
            }
            return(response);
        }
Ejemplo n.º 4
0
        public Task <RemoveRoleResponse> RemoveRole(RemoveRoleRequest request)
        {
            if (request.Ids.Count == 0)
            {
                return(Task.FromResult(new RemoveRoleResponse()
                {
                    Data = false,
                    Errors = "Không tìm thấy thông tin để xóa"
                }));
            }

            _repoRole.BulkRemove(x => request.Ids.Any(e => e.Equals(x.Id)));

            return(Task.FromResult(new RemoveRoleResponse()
            {
                Data = true
            }));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> RemoveRole([FromBody] RemoveRoleRequest request)
        {
            var user = await _userManager.FindByNameAsync(request.UserName);

            if (user == null)
            {
                return(BadRequest("User does not exist."));
            }

            if (!await _roleManager.RoleExistsAsync(request.RoleName))
            {
                return(BadRequest("Role does not exist."));
            }

            await _userManager.RemoveFromRoleAsync(user, request.RoleName);

            return(Ok($"{user.UserName} is not {request.RoleName} anymore"));
        }
Ejemplo n.º 6
0
 public Task <HttpResponseMessage> RemoveRole([FromBody] RemoveRoleRequest request)
 {
     return(ExecuteAction(request, Repository.RemoveRole));
 }
Ejemplo n.º 7
0
 public BaseResponse RemoveRole(RemoveRoleRequest request)
 {
     IdentityRepository.RemoveRole(request.Role);
     return(BaseResponse.Ok());
 }