public async Task <IActionResult> Delete([FromBody] BuildingUserDto buildingUserDto) { //Get header token if (Request.Headers.TryGetValue("Authorization", out StringValues headerValues)) { var token = _customEncoder.DecodeBearerAuth(headerValues.First()); if (token != null) { var user = await _userService.GetUserAsyncByToken(token); if (user != null) { //Verify if the token exist and is not expire if ((await _authenticationService.CheckIfTokenIsValidAsync(token) && user.IsAdmin == 1) || await _authenticationService.CheckIfTokenIsValidAsync(token, user.UserId)) { var isDeleted = await _buildingService.DeleteBuildingUserAsync(buildingUserDto); if (isDeleted == false) { return(StatusCode(404, "Unable to delete building user.")); } return(StatusCode(204, "Building User has been deleted.")); } return(StatusCode(401, "Invalid token.")); } return(StatusCode(403, "Invalid user.")); } return(StatusCode(401, "Invalid authorization.")); } return(StatusCode(401, "Invalid authorization.")); }