public ActionResult Create(Education education) { if (ModelState.IsValid) { db.Educations.Add(education); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.PersonalInfoId = new SelectList(db.PersonalInformations, "Id", "FathersName", education.PersonalInfoId); ViewBag.ConcentrationMajorGroupId = new SelectList(db.ConcentrationMajorGroups, "Id", "Type", education.ConcentrationMajorGroupId); return View(education); }
public ActionResult Create(Education education) { if (ModelState.IsValid) { var membership = (SimpleMembershipProvider)Membership.Provider; int idUser = membership.GetUserId(User.Identity.Name); int id = manager.GetPersonalInfoIdOfCurrentUser(idUser); education.PersonalInfoId = id; db.Educations.Add(education); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.PersonalInfoId = new SelectList(db.PersonalInformations, "Id", "FirstName", education.PersonalInfoId); ViewBag.ConcentrationMajorGroupId = new SelectList(db.ConcentrationMajorGroups, "Id", "Type", education.ConcentrationMajorGroupId); ViewBag.InstitutionId = new SelectList(db.Institutions, "Id", "Name", education.InstitutionId); ViewBag.EducationLevelId = new SelectList(db.EducationLevels, "Id", "Level", education.EducationLevelId); return View(education); }
public ActionResult Edit(Education education) { if (ModelState.IsValid) { db.Entry(education).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.PersonalInfoId = new SelectList(db.PersonalInformations, "Id", "FirstName", education.PersonalInfoId); ViewBag.ConcentrationMajorGroupId = new SelectList(db.ConcentrationMajorGroups, "Id", "Type", education.ConcentrationMajorGroupId); ViewBag.InstitutionId = new SelectList(db.Institutions, "Id", "Name", education.InstitutionId); ViewBag.EducationLevelId = new SelectList(db.EducationLevels, "Id", "Level", education.EducationLevelId); return View(education); }