Example #1
0
        public StudentDetailsVm GetStudentDetails(int id)
        {
            Student          student = this.Context.Students.FirstOrDefault(s => s.Id == id);
            StudentDetailsVm vm      = Mapper.Instance.Map <Student, StudentDetailsVm>(student);

            return(vm);
        }
Example #2
0
        public IActionResult Details(int id)
        {
            //Viewmodel aanmaken
            var studentDetailsVm = new StudentDetailsVm();

            //Viewmodel vullen
            studentDetailsVm.StudentId   = studentRepository.GetStudents().FirstOrDefault(s => s.Id == id)?.Id ?? 0;
            studentDetailsVm.StudentName = $"{studentRepository.GetStudents().FirstOrDefault(s => s.Id == id)?.FirstName ?? "no firstname"} " +
                                           $"{studentRepository.GetStudents().FirstOrDefault(s => s.Id == id)?.LastName ?? "noLastName"}";
            studentDetailsVm.CourseName = studentRepository.GetStudents().FirstOrDefault(s => s.Id == id)?.Course?.Name ?? "noCourse";

            return(View(studentDetailsVm));
        }