Example #1
0
        /// <summary>
        /// Gets list containing details of a particular student
        /// </summary>
        /// <param name="studentID">ID of a particular Student</param>
        /// <returns>Generic list of type Student View model</returns>
        /// <exception cref="Exception">Handles Exception</exception>
        public List <StudentVM> GetStudentData(string studentID)
        {
            List <StudentVM> result = new List <StudentVM>();

            try
            {
                StudentVM              studentVM      = new StudentVM();
                List <StudentModel>    studentList    = studentDataService.GetStudentData(studentID);
                List <DepartmentModel> departmentList = studentDataService.GetDepartmentData();

                result = studentList.Join(
                    departmentList,
                    student => student.departmentID,
                    department => department.departmentId,

                    (student, department) => new StudentVM
                {
                    studentID      = student.studentID,
                    studentName    = student.studentName,
                    studentEmail   = student.studentEmail,
                    studentGender  = student.studentGender,
                    dateofBirth    = student.dateofBirth,
                    departmentName = department.departmentName,
                    depatmentID    = department.departmentId
                }
                    ).ToList();
            }
            catch (Exception exception)
            {
                log.Info("\n----------Exception------\n");
                log.Error(exception.ToString());
            }
            return(result);
        }