public async Task <IActionResult> Register([FromBody] RegistrationViewModel model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // Check if password equals confirmPassword if (model.Password != model.ConfirmPassword) { return(new BadRequestObjectResult(Errors.AddErrorToModelState("Confirm", "Пароли не совпадают", ModelState))); } // check email //if(!new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$").Match(model.Email).Success) //{ // return new BadRequestObjectResult(Errors.AddErrorToModelState("UserName", "Введенное значение не имеет формат Email", ModelState)); //} IdentityResult result = await _accountBll.RegisterAccount(model); if (!result.Succeeded) { return(new BadRequestObjectResult(Errors.AddErrorsToModelState(result, ModelState))); } return(new OkObjectResult("Account created")); } catch (Exception ex) { throw new Exception("Ошибка при регистрации нового аккаунта" + ex.Message + ex.InnerException); } }