public ActionResult ShowEstudentes() { /* Create multiple instances of the Estudente class here in the Controller under the 'ShowEstudentes' method * Note: The logic to instantiate a Model class is performed in the Controller under a Method */ Estudente alex = new Estudente(); alex.StudentId = 1; alex.StudentFirstName = "Alex"; alex.StudentLastName = "Rodriguez"; Estudente lynda = new Estudente(); lynda.StudentId = 2; lynda.StudentFirstName = "Lynda"; lynda.StudentLastName = "Berry"; Estudente john = new Estudente(); john.StudentId = 3; john.StudentFirstName = "John"; john.StudentLastName = "Stewart"; // To send multiple student records to the viewpage 'ShowEstudentes' invoke the 'listview', as follows: List<Estudente> estudentes = new List<Estudente>(); estudentes.Add(alex); estudentes.Add(lynda); estudentes.Add(john); // To send mutiple student records to the viewpage 'ShowEstudentes', invoke the view for the entire collection return View(estudentes); }
public ActionResult ShowCourseStudents() { /* Create multiple instances of the Estudente class here in the Controller under the 'ShowEstudentes' method * Note: The logic to instantiate a Model class is performed in the Controller under a Method */ Estudente alex = new Estudente(); alex.StudentId = 1; alex.StudentFirstName = "Alex"; alex.StudentLastName = "Rodriguez"; Estudente lynda = new Estudente(); lynda.StudentId = 2; lynda.StudentFirstName = "Lynda"; lynda.StudentLastName = "Berry"; Estudente john = new Estudente(); john.StudentId = 3; john.StudentFirstName = "John"; john.StudentLastName = "Stewart"; /* Create an instance of the Course class in the Controller under the 'ShowCoursesStudents' method * Note: The logic to instantiate a Model class is performed in the Controller under a Method */ Course computerscience = new Course(); computerscience.CourseId = "CS 107"; computerscience.CourseName = "Computer Systems"; computerscience.CourseTotalCredit = 3; // To send multiple student records to the viewpage 'ShowEstudentes' invoke the 'listview', as follows: List<Estudente> estudentes = new List<Estudente>(); estudentes.Add(alex); estudentes.Add(lynda); estudentes.Add(john); // To send disparate Objects to the same viewpage, instantiate an instance of the combo class Course_Students obj = new Course_Students(); obj.course = computerscience; obj.students = estudentes; // To send mutiple student records to the viewpage 'ShowEstudentes' along with other objects, invoke the view for the 'obj' return View(obj); }
public ActionResult ShowEstudenteSolo() { /* Create multiple instances of the Estudente class here in the Controller under the 'ShowEstudenteSolo' method * Note: The logic to instantiate a Model class is performed in the Controller under a Method */ Estudente alex = new Estudente(); alex.StudentId = 1; alex.StudentFirstName = "Alex"; alex.StudentLastName = "Rodriguez"; Estudente lynda = new Estudente(); lynda.StudentId = 2; lynda.StudentFirstName = "Lynda"; lynda.StudentLastName = "Berry"; Estudente john = new Estudente(); john.StudentId = 3; john.StudentFirstName = "John"; john.StudentLastName = "Stewart"; // To send one student record to the viewpage 'ShowEstudentes', invoke the view for the record name only return View(alex); }