public ActionResult Create([Bind(Include = "SearchResultsID,CompanionID,Name,StateName,City,Accreditor,Ownership,Cost,ZipCode,Degree,DegreeType")] SearchResult searchResult)
        {
            if (ModelState.IsValid)
            {
                db.SearchResults.Add(searchResult);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CompanionID = new SelectList(db.CompanionUsers, "CompanionID", "Email", searchResult.CompanionID);
            return(View(searchResult));
        }
 /// <summary>
 /// Saves a college to the database.
 /// </summary>
 /// <param name="college">Takes a database.</param>
 public void SaveCollege(SearchResult college)
 {
     if (college == null)
     {
         throw new ArgumentNullException(nameof(college));
     }
     Context.SaveChanges();
 }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            RecaptchaVerificationHelper recaptchaHelper = this.GetRecaptchaVerificationHelper();

            if (string.IsNullOrEmpty(recaptchaHelper.Response))
            {
                ModelState.AddModelError("reCAPTCHA", "Please complete the reCAPTCHA");
                // If we got this far, something failed, redisplay form
                return(View(model));
            }
            else
            {
                RecaptchaVerificationResult recaptchaResult = recaptchaHelper.VerifyRecaptchaResponse();
                if (recaptchaResult != RecaptchaVerificationResult.Success)
                {
                    ModelState.AddModelError("reCAPTCHA", "The reCAPTCHA is incorrect");
                    // If we got this far, something failed, redisplay form
                    return(View(model));
                }
            }
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };

                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://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);
                    await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    //Replace this with Repository Pattern!!
                    CompanionContext db       = new CompanionContext();
                    CompanionUser    compUser = new CompanionUser();
                    compUser.ASPIdentityID = user.Id;
                    compUser.Email         = user.Email;
                    db.CompanionUsers.Add(compUser);
                    db.SaveChanges();

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }