public async Task <ActionResult> CreateDonator(CreateDonatorViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { FirstName = model.FirstName, LastName = model.LastName, UserName = model.Email, Email = model.Email, CreditCard = new CreditCard() { CVV = model.CVV, CardNumber = model.CardNumber, CardOwner = model.CardOwner, Year = model.Year, Month = model.Month, CardType = model.CardType } }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { // await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); await this.UserManager.AddToRoleAsync(user.Id, model.UserRoles); return(RedirectToAction("Index", "Account")); } //ViewBag.Name = new SelectList(db.Roles.Where(u => !u.Name.Contains("Admin")) // .ToList(), "Name", "Name"); AddErrors(result); } return(View(model)); }
public ActionResult CreateDonator() { var viewModel = new CreateDonatorViewModel() { UserRoles = "Donator" }; return(View(viewModel)); }