public ActionResult editProfile(profile prof) { prof.email = User.Identity.Name; if (ModelState.IsValid) { profile profileExists = dbprof.profiles.Where(b => b.email == prof.email).FirstOrDefault(); if (profileExists != null) { profileExists.about = prof.about; profileExists.country = prof.country; profileExists.firstName = prof.firstName; profileExists.lastName = prof.lastName; profileExists.searchRadius = prof.searchRadius; profileExists.tags = prof.tags; profileExists.zipcode = prof.zipcode; dbprof.SaveChanges(); return RedirectToAction("Index", "dashboard"); } else ModelState.AddModelError("", "There is no user with this email address."); } return View(); }
public ActionResult individual(user input) { if (ModelState.IsValid) { @ViewBag.login = false; org orgExists = dborg.orgs.Where(a => a.email == input.email).FirstOrDefault(); user userExists = dbuser.users.Where(b => b.email == input.email).FirstOrDefault(); profile newProf = new profile(); if ((userExists == null)&&(orgExists == null)) { input.password = encryptPassword(input.password); dbuser.users.Add(input); dbuser.SaveChanges(); newProf.email = input.email; newProf.firstName = input.firstName; newProf.lastName = input.lastName; newProf.country = input.country; newProf.zipcode = input.zipcode; newProf.searchRadius = 100; newProf.about = null; newProf.tags = null; dbprof.profiles.Add(newProf); dbprof.SaveChanges(); return RedirectToAction("Index", "login"); } else if (userExists != null) { ModelState.AddModelError("","An individual user already exists for the email address."); } else ModelState.AddModelError("", "An organization already has an account using this email address."); } return View(); }