public async Task <IdentityResult> Register(string email, string password, string title, string firstName, string lastName) { // Luo käyttäjä var user = new ApplicationUser { UserName = email, Email = email, FirstName = firstName, LastName = lastName }; var result = await userManager.CreateAsync(user, password); if (!result.Succeeded) { return(result); } // Luo yritys var business = new Business() { OwnerApplicationUser = user, Title = title, }; await businessStore.Create(business); // Lähetä sähköposti, jossa pyydetään mm varmistamaan sähköpostiosoite var emailConfirmToken = await userManager.GenerateEmailConfirmationTokenAsync(user); await notificationSender.SendBusinessRegistered(business, emailConfirmToken); return(result); }
public async Task Register(ApplicationUser user, Business business) { // Seuraavat kaksi voisi tehdä tietokanta transactionissa await userManager.CreateAsync(user); await businessStore.Create(business); await notificationSender.SendBusinessRegistered(business); }