public async Task <IActionResult> Register(RegisterCustomerViewModel registerCustomerViewModel) { if (!ModelState.IsValid) { return(View(registerCustomerViewModel)); } var customerDetails = new Customer(Guid.NewGuid(), registerCustomerViewModel.Name, 0); var customer = new ApplicationUser { Id = customerDetails.Id.ToString(), UserName = registerCustomerViewModel.Email, Email = registerCustomerViewModel.Email, CustomerDbModelId = customerDetails.Id, CreationTime = DateTimeOffset.Now }; _customerRepository.AddOne(customerDetails); var result = await _userManager.CreateAsync(customer, registerCustomerViewModel.Password); if (result.Succeeded) { await _signInManager.SignInAsync(customer, false); return(RedirectToAction(IndexAction, DefaultController)); } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); return(View(registerCustomerViewModel)); } return(View(registerCustomerViewModel)); }