public ActionResult Edit(StudentParticular studentparticular) { if (ModelState.IsValid) { db.Entry(studentparticular).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(studentparticular)); }
public ActionResult Edit(int id = 0) { StudentParticular studentparticular = db.StudentParticulars.ToList().Where(p => p.id == id && p.student_id.ToString() == User.Identity.Name).SingleOrDefault(); if (studentparticular == null) { return(HttpNotFound("The record you selected does not exist. Please refresh the page.")); } return(View(studentparticular)); }
public ActionResult Delete(int id = 0) { StudentParticular studentparticular = db.StudentParticulars.ToList().Where(p => p.id == id && p.student_id.ToString() == User.Identity.Name).SingleOrDefault(); var student_id = studentparticular.student_id; if (studentparticular == null) { return(HttpNotFound("The record you selected does not exist. Please refresh the page.")); } db.StudentParticulars.Remove(studentparticular); db.SaveChanges(); return(RedirectToAction("MyParticular", "StudentProfile", new { student_id = student_id })); }
public ActionResult Create(StudentParticular studentparticular) { if (ModelState.IsValid) { db.StudentParticulars.Add(studentparticular); try { db.SaveChanges(); } catch (Exception e) { return(HttpNotFound("Failed to add particular.<br/><br/>" + e.Message)); } } return(RedirectToAction("MyParticular", "StudentProfile", new { student_id = studentparticular.student_id })); }
public ActionResult Create(int id = 0) { var type = db.StudentParticularTypes.Find(id); var student = db.StudentProfiles.Find(User.Identity.Name); if (student == null || type == null) { return(HttpNotFound("Student Profile or Particular Type not found.")); } StudentParticular particular = new StudentParticular { type_id = id, student_id = student.id, StudentProfile = student, StudentParticularType = type }; return(View(particular)); }