/// GET: Available student list /// //[Authorize] public ActionResult Index() { StudentListViewModel stuListVM = new StudentListViewModel(); List <Student> students = stuBL.GetStudents(); List <StudentViewModel> stuVMs = new List <StudentViewModel>(); foreach (Student stu in students) { StudentViewModel stuVM = new StudentViewModel(stu); stuVMs.Add(stuVM); } stuListVM.Students = stuVMs; return(View("Index", stuListVM)); }
public ActionResult Index() { StudentBusinessLayer sbl = new StudentBusinessLayer(); List <StudentModel> smList = new List <StudentModel>(); smList = sbl.GetStudents(); List <StudentViewModel> svmlist = new List <StudentViewModel>(); foreach (StudentModel item in smList) { StudentViewModel svm = new StudentViewModel(); svm.StudentName = item.FirstName + " " + item.LastName; svm.Age = item.Age; svm.AgeColor = svm.Age > 18 ? "Red" : "darkseagreen"; svmlist.Add(svm); } StudentListViewModel slvm = new StudentListViewModel(); slvm.Student = svmlist; slvm.UserName = User.Identity.Name; return(View("Index", slvm)); }