public ActionResult Create(StudentExperience studentexperience) { if (ModelState.IsValid) { db.StudentExperiences.Add(studentexperience); try { db.SaveChanges(); } catch (Exception e) { return HttpNotFound("Failed to add experience.<br/><br/>" + e.Message); } } return RedirectToAction("MyExperience", "StudentProfile", new { student_id = studentexperience.student_id }); }
public ActionResult Create(int id = 0) { var type = db.StudentExperienceTypes.Find(id); var student = db.StudentProfiles.Find(User.Identity.Name); if (student == null || type == null) { return HttpNotFound("Student Profile or Experience Type not found."); } StudentExperience studentexperience = new StudentExperience { type_id = id, student_id = student.id, StudentProfile = student, StudentExperienceType = type }; PrepareList(); return View(studentexperience); }
public ActionResult Edit(StudentExperience studentexperience) { if (ModelState.IsValid) { db.Entry(studentexperience).State = EntityState.Modified; db.SaveChanges(); } return RedirectToAction("MyExperience", "StudentProfile", new { student_id = studentexperience.student_id }); }