public async Task <IActionResult> CreateUser([FromBody] UserCreateDto dto) { if (dto == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var user = Mapper.Map <UserEntity>(dto); user = await userService.CreateUserAsync(user); #region User Rate Limit // set user rate limit var clientPolicy = RateLimitHelper.CreateUserRateLimitPolicy(user.ID, user.ThrottlingLimit, user.ThrottlingPeriod); if (clientPolicy != null && clientRateLimitOptions != null && clientPolicyStore != null && !clientPolicyStore.Exists(clientPolicy.ClientId)) { clientPolicyStore.Set($"{clientRateLimitOptions.ClientPolicyPrefix}_{clientPolicy.ClientId}", clientPolicy); } #endregion return(CreatedAtRoute("GetUser", new { Id = user.ID }, user)); } catch (CustomException e) { return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message)); } }