bool IsStudentHaveBook(int _studentId, int _bookId)
        {
            bool _checkIsValueExist           = false;
            List <BorrowList> _borrowsStudent = new Database.CRUD().SelectBorrowLists();


            IEnumerable <BorrowList> _filteringBorrows = _borrowsStudent.Where(s => s.EndRent.ToString("yyyy.MM.dd") ==
                                                                               DateTime.MaxValue.ToString("yyyy.MM.dd") && s.StudentId == _studentId);


            foreach (BorrowList i in _filteringBorrows)
            {
                if (i.BookId == _bookId && i.StudentId == _studentId)
                {
                    _checkIsValueExist = true;
                    break;
                }
                else if (_bookId == 0)
                {
                    _checkIsValueExist = true;
                    break;
                }
            }
            return(_checkIsValueExist);
        }
Exemple #2
0
        public void Run()
        {
            Console.WriteLine("{0,55}", "///   BOOKS, BORROWED BY THE STUDENT.   ///");
            Console.WriteLine();

            List <BorrowList> _borrowList = new Database.CRUD().SelectBorrowLists();
            int _studentId = 0;

            _studentId = new Functions().ChooseStudent();

            IEnumerable <BorrowList> _unavailableBorrowList = _borrowList.Where(s => s.EndRent.ToString("yyyy.MM.dd") ==
                                                                                DateTime.MaxValue.ToString("yyyy.MM.dd") && s.StudentId == _studentId);

            Student _newStudent = new Functions().SelectOneStudent(_studentId);

            new Functions().OutputStudent(_newStudent);

            Console.WriteLine("{0,55}", "TABLE 'BOOKS BORROWED BY THE STUDENT'\n");
            Console.WriteLine("| {0,-8} | {1,30}  |",
                              "BOOK ID", "BOOK NAME");

            foreach (BorrowList i in _unavailableBorrowList)
            {
                Console.WriteLine("| {0,-8} | {1,30}  |",
                                  i.BookId, i.Book.Name);
            }

            Console.ReadKey();
        }
        public void Run()
        {
            Console.WriteLine("{0,55}", "///   LESSONS, VISITED BY STUDENT.   ///");
            Console.WriteLine();


            List <VisitedLessonsList> _visitedLessons = new Database.CRUD().SelectVisitedList();
            int _studentId = 0;

            _studentId = new Functions().ChooseStudent();

            IEnumerable <VisitedLessonsList> _filteringLessons = _visitedLessons.Where(s => s.StudentId == _studentId);

            Student _newStudent = new Functions().SelectOneStudent(_studentId);

            new Functions().OutputStudent(_newStudent);

            Console.WriteLine("{0,55}", "TABLE 'LESSONS VISITED BY THE STUDENT'\n");
            Console.WriteLine("| {0,-4} | {1,25}  | {2,20} |",
                              "ID", "LESSON NAME", "BOOK NAME");


            foreach (VisitedLessonsList i in _filteringLessons)
            {
                Console.WriteLine("| {0,-4} | {1,25}  | {2,20} |",
                                  i.VisitedLessonsListId, i.Lesson.Name, i.Book.Name);
            }

            Console.ReadKey();
        }