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);
        }
        public void Run()
        {
            Console.WriteLine("{0,55}", "///   SHOW BORROW LIST.   ///");
            Console.WriteLine();


            List <BorrowList> _borrows = new Database.CRUD().SelectBorrowLists();
            dynamic           _endRent;

            Console.WriteLine("{0,55}", "TABLE 'BORROW LIST'\n");
            Console.WriteLine("| {0,-7} | {1,-7} | {2,20} | {3,11} | {4,14} | {5,10} | {6,12} | {7,15} | {8,10} | {9,10} |",
                              "ID", "BOOK ID", "BOOK NAME", "AUTHOR NAME", "AUTHOR SURNAME", "STUDENT ID", "STUDENT NAME", "STUDENT SURNAME", "START RENT", "END RENT");


            foreach (BorrowList i in _borrows)
            {
                if (i.EndRent.ToString("yyyy.MM.dd") == DateTime.MaxValue.ToString("yyyy.MM.dd"))
                {
                    _endRent = " ----- ";
                }
                else
                {
                    _endRent = i.EndRent.ToString("yyyy.MM.dd");
                }

                Console.WriteLine("| {0,-7} | {1,-7} | {2,20} | {3,11} | {4,14} | {5,10} | {6,12} | {7,15} | {8,10} | {9,10} |",
                                  i.BorrowListId, i.BookId, i.Book.Name, i.Book.Author.Name, i.Book.Author.Surname, i.StudentId, i.Student.Name, i.Student.Surname, i.StartRent.ToString("yyyy.MM.dd"), _endRent);
            }
            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();
        }
Esempio n. 4
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 Book SelectOneBook(int _userChoise)
        {
            Book        _targetBook = new Book();
            List <Book> _books      = new Database.CRUD().SelectBooks();

            _targetBook = _books.Find(i => i.BookId == _userChoise);
            return(_targetBook);
        }
        public Lesson SelectOneLesson(int _inputLessonId)
        {
            Lesson        _targetLesson = new Lesson();
            List <Lesson> _lessonsList  = new Database.CRUD().SelectLessons();

            _targetLesson = _lessonsList.Find(i => i.LessonId == _inputLessonId);
            return(_targetLesson);
        }
        public BorrowList SelectOneBorrowList(int _userChoise)
        {
            BorrowList        _targetBorrow = new BorrowList();
            List <BorrowList> _borrows      = new Database.CRUD().SelectBorrowLists();

            _targetBorrow = _borrows.Find(i => i.BorrowListId == _userChoise);
            return(_targetBorrow);
        }
        Faculty SelectFaculty(int _userChange)
        {
            Faculty        _targetFaculty = new Faculty();
            List <Faculty> _listFaculty   = new Database.CRUD().SelectFaculties();

            _targetFaculty = _listFaculty.Find(i => i.FacultyId == _userChange);
            return(_targetFaculty);
        }
Esempio n. 9
0
        Author SelectAuthor(int _userChoise)
        {
            Author        _targetAuthor  = new Author();
            List <Author> _listOfAuthors = new Database.CRUD().SelectAuthors();

            _targetAuthor = _listOfAuthors.Find(i => i.AuthorId == _userChoise);

            return(_targetAuthor);
        }
        public Student SelectOneStudent(int _userChoise)
        {
            Student        _targetStudent = new Student();
            List <Student> _students      = new Database.CRUD().SelectStudents();

            _targetStudent = _students.Find(i => i.StudentId == _userChoise);

            return(_targetStudent);
        }
        bool IsBookAvailable(int _userChoise)
        {
            bool        _checkIsValueAvailable = false;
            List <Book> _books      = new Database.CRUD().SelectBooks();
            Book        _chosenBook = _books.Find(i => i.BookId == _userChoise);

            if (_chosenBook.IsAvailable)
            {
                _checkIsValueAvailable = true;
            }

            return(_checkIsValueAvailable);
        }
        bool IsBorrowExist(int _userChoise)
        {
            bool _checkIsValueExist       = false;
            List <BorrowList> _borrowList = new Database.CRUD().SelectBorrowLists();

            foreach (BorrowList i in _borrowList)
            {
                if (i.BorrowListId == _userChoise)
                {
                    _checkIsValueExist = true;
                }
            }
            return(_checkIsValueExist);
        }
        bool IsFacultyExist(int _input)
        {
            List <Faculty> _faculties         = new Database.CRUD().SelectFaculties();
            bool           _checkIsValueExist = false;

            foreach (Faculty i in _faculties)
            {
                if (i.FacultyId == _input)
                {
                    _checkIsValueExist = true;
                }
            }

            return(_checkIsValueExist);
        }
        bool IsLessonExist(int _inputLessoId)
        {
            List <Lesson> _listLessons       = new Database.CRUD().SelectLessons();
            bool          _checkIsValueExist = false;

            foreach (Lesson i in _listLessons)
            {
                if (i.LessonId == _inputLessoId)
                {
                    _checkIsValueExist = true;
                    break;
                }
            }
            return(_checkIsValueExist);
        }
Esempio n. 15
0
        bool IsAuthorExist(int _userChoise)
        {
            List <Author> _listAuthor        = new Database.CRUD().SelectAuthors();
            bool          _checkIsValueExist = false;


            foreach (Author i in _listAuthor)
            {
                if (i.AuthorId == _userChoise)
                {
                    _checkIsValueExist = true;
                }
            }

            return(_checkIsValueExist);
        }
        bool IsBookExist(int _userChoise)
        {
            List <Book> _ListBooks         = new Database.CRUD().SelectBooks();
            bool        _checkIsValueExist = false;

            foreach (Book i in _ListBooks)
            {
                if (i.BookId == _userChoise)
                {
                    _checkIsValueExist = true;
                    break;
                }
            }

            return(_checkIsValueExist);
        }
        bool IsStudentExist(int _userChoise)
        {
            List <Student> _listStudent       = new Database.CRUD().SelectStudents();
            bool           _checkIsValueExist = false;


            foreach (Student i in _listStudent)
            {
                if (i.StudentId == _userChoise)
                {
                    _checkIsValueExist = true;
                }
            }

            return(_checkIsValueExist);
        }
        public void Run()
        {
            Console.WriteLine("{0,55}", "///   SHOW ALL AUTHORS.   ///");
            Console.WriteLine();

            List <Author> _authors = new Database.CRUD().SelectAuthors();

            System.Linq.IOrderedEnumerable <Author> _sortedAuthors = from u in _authors orderby u.AuthorId ascending select u;
            Console.WriteLine("{0,55}", "TABLE 'AUTHORS'\n");
            Console.WriteLine("| {0,-5} | {1,15}  |  {2,15}  |",
                              "ID", "NAME", "SURNAME");
            Console.WriteLine();
            foreach (Author i in _authors)
            {
                Console.WriteLine("| {0,-5} | {1,15}  |  {2,15}  |",
                                  i.AuthorId, i.Name, i.Surname);
            }
            Console.ReadKey();
        }
Esempio n. 19
0
        public void Run()
        {
            Console.WriteLine("{0,55}", "///   SHOW ALL LESSONS.   ///");
            Console.WriteLine();

            List <Lesson> _lessons = new Database.CRUD().SelectLessons();

            System.Linq.IOrderedEnumerable <Lesson> _sortedLesson = from u in _lessons orderby u.Name ascending select u;

            Console.WriteLine("{0,55}", "TABLE 'LESSONS'\n");
            Console.WriteLine("| {0,-5} | {1,26} |", "ID", "NAME");
            Console.WriteLine();

            foreach (Lesson i in _sortedLesson)
            {
                Console.WriteLine("| {0,-5} | {1,26} |", i.LessonId, i.Name);
            }
            Console.ReadKey();
        }
Esempio n. 20
0
        public void Run()
        {
            Console.WriteLine("{0,55}", "///   SHOW ALL VISITED LESSON LIST.   ///");
            Console.WriteLine();

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

            Console.WriteLine("{0,55}", "TABLE 'VISITED LESSONS LIST'\n");
            Console.WriteLine("| {0,-4} | {1,11} | {2,18} | {3,18} | {4,7} | {5,8} | {6,27} | {7,18} |",
                              "ID", "STUDENT ID", "STUDENT NAME", "STUDENT SURNAME", "COURSE", "FACULTY", "LESSON NAME", "BOOK NAME");

            foreach (VisitedLessonsList i in _visitedLessons)
            {
                Console.WriteLine("| {0,-4} | {1,11} | {2,18} | {3,18} | {4,7} | {5,8} | {6,27} | {7,18} |",
                                  i.VisitedLessonsListId, i.StudentId, i.Student.Name, i.Student.Surname, i.Student.Course, i.Student.Faculty.Name, i.Lesson.Name, i.Book.Name);
            }


            Console.ReadKey();
        }
        public void Run()
        {
            Console.WriteLine("{0,55}", "///   SHOW ALL BOOKS.   ///");
            Console.WriteLine();

            List <Book> _books = new List <Book>();

            _books = new Database.CRUD().SelectBooks();

            System.Linq.IOrderedEnumerable <Book> _sortedBooks = from u in _books orderby u.Author.Surname ascending select u;

            Console.WriteLine("{0,55}", "TABLE 'BOOKS'\n");
            Console.WriteLine("| {0,-5} | {1,25} | {2,15} | {3,15} | {4,20} | {5,20} |",
                              "ID", "NAME", "YEAR OF PUBLISH", "AUTHOR NAME", "AUTHOR SURNAME", "IS AVAILABLE");
            Console.WriteLine();

            foreach (Book i in _sortedBooks)
            {
                Console.WriteLine("| {0,-5} | {1,25} | {2,15} | {3,15} | {4,20} | {5,20} |",
                                  i.BookId, i.Name, i.YearOfPublish, i.Author.Name, i.Author.Surname, i.IsAvailable);
            }
            Console.ReadKey();
        }
        public void Run()
        {
            Console.WriteLine("{0,55}", "///   SHOW ALL STUDENTS.   ///");
            Console.WriteLine();

            List <Student> _studentList = new List <Student>();

            _studentList = new Database.CRUD().SelectStudents();

            System.Linq.IOrderedEnumerable <Student> _sortedStudentList = from u in _studentList orderby u.Course ascending select u;

            Console.WriteLine("{0,55}", "TABLE 'STUDENTS'\n");
            Console.WriteLine("| {0,-5} | {1,15}  |  {2,15}  |  {3,20}  |  {4,8}  |  {5,15} |",
                              "ID", "NAME", "SURNAME", "DATE OF BIRTH", "COURSE", "FACULTY");
            Console.WriteLine();
            foreach (Student i in _sortedStudentList)
            {
                Console.WriteLine("| {0,-5} | {1,15}  |  {2,15}  |  {3,20}  |  {4,8}  |  {5,15} |",
                                  i.StudentId, i.Name, i.Surname, i.BirthDate.ToString("yyyy.MM.dd"), i.Course, i.Faculty.Name);
            }

            Console.ReadKey();
        }