Exemple #1
0
        public async Task <IActionResult> RegisterUser([FromBody] CreateUser model)
        {
            if (ModelState.IsValid)
            {
                _logger.LogInformation(
                    "----- recieving request Createuser : {model} : Data ({data})",
                    model.GetGenericTypeName(),
                    model.GetObjectAsJson());

                var commandResult = await _accountService.RegisterAsync(model);

                if (!commandResult)
                {
                    return(BadRequest());
                }

                var user = await _accountService.GetUserAsync(model.Email);

                _bus.Publish(new UserCreatedEvent(user.Id));

                return(Ok());
            }
            else
            {
                throw new TcsException("invalid_data",
                                       ModelState.Values.SelectMany(v => v.Errors));
            }
        }