public ActionResult SaveStudent(StudentViewModel model) { //This will run when new student is added to the list. if (model.Student.StudentId == 0) { //Getting Student id by passing model to AddStudentBySP method and passing it as a parameter in AddCoursesBySP method. studentRepository.AddCoursesBySP(model, studentRepository.AddStudentBySP(model)); } //This code will run when we will update student record. else { studentRepository.Update(model.Student); studentRepository.UpdatestudentCourse(model); } return(RedirectToAction("StudentList")); }