public async Task<ActionResult> Register(RegisterDonorViewModel registration) { var userManager = HttpContext.GetOwinContext().GetUserManager<WishlistUserManager>(); var user = await CreateDonor(registration, userManager); if (registration.DonorId.HasValue) { await AuthorizeDonorForUser(user, registration.DonorId.Value, userManager); await SendConfirmationEmail(user, userManager); await SignDonorIn(user, userManager); return RedirectToAction("Index", "Home"); } var donor = new Donor(); _db.Donors.Add(donor); var cart = new Cart { Donor = donor, ModifiedDate = DateTime.Now }; _db.Carts.Add(cart); await _db.SaveChangesAsync(); await AuthorizeDonorForUser(user, donor.Id, userManager); await SendConfirmationEmail(user, userManager); await SignDonorIn(user, userManager); return RedirectToAction("Index", "Home"); }
private async Task<WishlistUser> CreateDonor(RegisterDonorViewModel registration, WishlistUserManager manager) { await manager.CreateAsync(new WishlistUser { Name = registration.Name, UserName = registration.Email, Email = registration.Email }, registration.Password); return await manager.FindByNameAsync(registration.Email); }