using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using AttributeRoutingDemoInMVC.Models; namespace AttributeRoutingDemoInMVC.Controllers { public class StudentsController : Controller { private static List students = new List() { new Student() {Id = 1, Name = "Pranaya"}, new Student() {Id = 2, Name = "Priyanka"}, new Student() {Id = 3, Name = "Anurag"}, new Student() {Id = 4, Name = "Sambit"} }; [HttpGet] public ActionResult GetAllStudents() { return View(students); } [HttpGet] public ActionResult GetStudentByID(int studentID) { Student studentDetails = students.FirstOrDefault(s => s.Id == studentID); return View(studentDetails); } [HttpGet] public ActionResult GetStudentCourses(int studentID) { List CourseList = new List(); if (studentID == 1) CourseList = new List() { "ASP.NET", "C#.NET", "SQL Server" }; else if (studentID == 2) CourseList = new List() { "ASP.NET MVC", "C#.NET", "ADO.NET" }; else if (studentID == 3) CourseList = new List() { "ASP.NET WEB API", "C#.NET", "Entity Framework" }; else CourseList = new List() { "Bootstrap", "jQuery", "AngularJs" }; ViewBag.CourseList = CourseList; return View(); } } }