public async Task <IActionResult> Register(ExecutiveRegistration rep) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var appUser = await AuthServices.Register(rep); if (appUser.IsVerified) { return(Created("", appUser)); } return(BadRequest(appUser)); }
public async Task <AppUser> Register(ExecutiveRegistration representative) { var userName = await UserManager.FindByEmailAsync(representative.Email); if (userName != null) { return(new AppUser() { ErrorMessage = "Email already Exsit" }); } var user = new User() { UserName = representative.Email, Email = representative.Email, Firstname = representative.Firstname, Lastname = representative.Lastname, PhoneNumber = representative.Mobile }; var result = await UserManager.CreateAsync(user, representative.Password); if (result.Succeeded) { return(await Login(new Auth { Email = representative.Email, Password = representative.Password })); } AppUser appUser = new AppUser(); foreach (var error in result.Errors) { appUser.ErrorMessage = "\n" + error.Description; } return(appUser); }