public async Task <IActionResult> CreateUser([FromBody] NewUserCreationRequest newUserCreationRequest)
        {
            var newUser = _mapper.Map <User>(newUserCreationRequest);

            await _userRepository.AddUser(newUser);

            await _unitOfWork.CompleteAsync();

            return(CreatedAtAction(nameof(GetUser), new { userId = newUser.Id }, newUser));
        }
        public async Task <User> CreateUser(NewUserCreationRequest newUserCreationRequest)
        {
            var client   = _clientFactory.CreateClient("UserService");
            var content  = new StringContent(JsonSerializer.Serialize <NewUserCreationRequest>(newUserCreationRequest), Encoding.UTF8, "application/json");
            var response = await client.PostAsync("users", content);

            response.EnsureSuccessStatusCode();

            return(JsonSerializer.Deserialize <User>(await response.Content.ReadAsStringAsync()));
        }
Exemple #3
0
        public async Task <IActionResult> CreateUser([FromBody] NewUserCreationRequest newUserCreationRequest)
        {
            var user = await _userService.CreateUser(newUserCreationRequest);

            return(CreatedAtAction(nameof(GetUser), new { userId = user.Id }, user));
        }