public ActionResult Application() { var currentUserEmail = User.Identity.Name; if (_db.ApplicantPersons.Any(u => u.EmailAddress == currentUserEmail)) { var applicant = new ApplicantPerson { EmailAddress = User.Identity.Name }; _db.ApplicantPersons.Attach(applicant); _db.Entry(applicant).Property(x => x.EmailAddress).IsModified = true; _db.SaveChanges(); } var familyMembers = _db.sp_ApplicantFamily_SelectFamilyMembers(User.Identity.Name).ToList(); List <ApplicantVm> applicantVmList = new List <ApplicantVm>(); ApplicantVm applicantVm = new ApplicantVm(); foreach (var child in familyMembers) { foreach (var student in applicantVm.studentList) { student.FirstName = child.FirstName; } } return(View(applicantVm)); }
public ActionResult Register() { var currentUserEmail = User.Identity.Name; var student = _db.ApplicantStudents.ToList(); var applicantexists = _db.ApplicantPersons.Where(p => p.EmailAddress == currentUserEmail). Select(e => e.EmailAddress).FirstOrDefault(); // var applicantexists = _db.applicantpersons.any(u => u.emailaddress == currentuseremail); if (!_db.ApplicantPersons.Any(u => u.EmailAddress == currentUserEmail)) { var applicant = new ApplicantPerson { EmailAddress = User.Identity.Name }; _db.ApplicantPersons.Add(applicant); //_db.applicantpersons.attach(applicant); //_db.entry(applicant).property(x => x.emailaddress).ismodified = true; _db.SaveChanges(); } return(View()); }