public ActionResult SubmitHighSchoolInfoPartial(HighSchoolInfo highSchoolInfo) { Guid UserID = Guid.Parse(HttpContext.User.Identity.GetUserId()); using (UserContext db = new UserContext()) { var data = db.Users .Include(u => u.SchoolInfo) .Include(u => u.SchoolInfo.HighSchoolInformation) .Where(u => u.UserID == UserID) .FirstOrDefault <UserModel>(); if (data.SchoolInfo == null) { data.SchoolInfo = new SchoolInfo(); data.SchoolInfo.HighSchoolInformation = new List <HighSchoolInfo>(); } data.SchoolInfo.UserID = UserID; highSchoolInfo.UserID = UserID; data.SchoolInfo.HighSchoolInformation.Add(highSchoolInfo); db.SaveChanges(); return(GetHighSchoolInfo(data.SchoolInfo.HighSchoolInformation)); } }
public void DeleteHighSchool(string fieldId) { HighSchoolInfo hsi = new HighSchoolInfo(); hsi.fieldId = Int32.Parse(fieldId); using (UserContext db = new UserContext()) { db.HighSchoolInfoes.Attach(hsi); db.HighSchoolInfoes.Remove(hsi); db.SaveChanges(); } }