Esempio n. 1
0
        /// <summary>
        /// Returns library details of a particular Course
        /// </summary>
        /// <param name="courseId">ID of a particular course</param>
        /// <returns>Generic list of type Library View model</returns>
        /// <exception cref="Exception">Handles Exception</exception>
        public List <LibraryVM> GetLibraryDetails(string courseId)
        {
            List <LibraryVM> result = new List <LibraryVM>();

            try
            {
                var libraryDetails = studentDataService.GetLibraryData().Where(library =>
                                                                               library.courseId.Equals(courseId));

                var courseDetails = studentDataService.GetCourseData().Where(course =>
                                                                             course.courseId.Equals(courseId));

                result = libraryDetails.Join(
                    courseDetails,
                    library => library.courseId,
                    course => course.courseId,
                    (library, course) => new LibraryVM
                {
                    courseId         = library.courseId,
                    courseName       = course.courseName,
                    authorName       = library.authorName,
                    rackNumber       = library.rackNumber,
                    yearOfPublishing = library.yearOfPublishing
                }
                    ).ToList();
            }
            catch (Exception exception)
            {
                log.Info("\n----------Exception------\n");
                log.Error(exception.ToString());
            }
            return(result);
        }