public ActionResult Sync(string userId) { var usersForms = db.Users.Find(userId).Forms; UserForm userForm = new UserForm() { Form = db.Forms.Find(4), IsComplete = false }; usersForms.Add(userForm); userForm = new UserForm() { Form = db.Forms.Find(5), IsComplete = false }; return RedirectToAction("MyForms", "Home"); }
public async Task<ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl) { if (User.Identity.IsAuthenticated) { return RedirectToAction("Manage"); } if (ModelState.IsValid) { // Get the information about the user from the external login provider var info = await AuthenticationManager.GetExternalLoginInfoAsync(); if (info == null) { return View("ExternalLoginFailure"); } var user = new ApplicationUser() { UserName = model.Email, Email = model.Email, Name = model.Name, Grade = model.Grade, HomeTown = model.HomeTown }; IdentityResult result = await UserManager.CreateAsync(user); if (result.Succeeded) { result = await UserManager.AddLoginAsync(user.Id, info.Login); if (result.Succeeded) { await SignInAsync(user, isPersistent: false); // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // SendEmail(user.Email, callbackUrl, "Confirm your account", "Please confirm your account by clicking this link"); var usersForms = db.Users.Find(user.Id).Forms; UserForm userForm = new UserForm() { Form = db.Forms.Find(1), IsComplete = false }; usersForms.Add(userForm); userForm = new UserForm() { Form = db.Forms.Find(2), IsComplete = false }; usersForms.Add(userForm); userForm = new UserForm() { Form = db.Forms.Find(3), IsComplete = false }; usersForms.Add(userForm); userForm = new UserForm() { Form = db.Forms.Find(4), IsComplete = false }; usersForms.Add(userForm); userForm = new UserForm() { Form = db.Forms.Find(5), IsComplete = false }; usersForms.Add(userForm); db.SaveChanges(); return RedirectToAction("Create", "Profiles"); //return RedirectToLocal(returnUrl); } } AddErrors(result); } ViewBag.ReturnUrl = returnUrl; return View(model); }