示例#1
0
        public async Task <IActionResult> CreateAccount([FromBody] RegisterModel registerModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var result = await _accountApplicationService.CreateAccount(registerModel);

            if (!result.Succeeded)
            {
                var errors = result.Errors.Select(e => e.Description);
                return(BadRequest(new RegisterResult()
                {
                    Successful = false, Errors = errors
                }));
            }
            return(Created("api/accounts/create", new RegisterResult()
            {
                Successful = true
            }));
        }