示例#1
0
        public List <Author> GetAuthorsForEdition()
        {
            string bookName = Helper.ReadString("Introduce the name of the book:");

            while (!BookDAL.CheckBook(bookName))
            {
                Helper.DisplayError("\n Wrong book name!");
                Console.ForegroundColor = ConsoleColor.Red;
                bookName = Helper.ReadString("Reintroduce the name of the book:");
            }

            List <Author> authors = null;

            int    PublicationYear     = Helper.ReadYear("Introduce the year of publishing:");
            string PublishingHouseName = Helper.ReadString("Introduce publishing house name:");

            while (!EditionDAL.CheckEdition(bookName, PublishingHouseName, PublicationYear))
            {
                Helper.DisplayError("\n Edition doesn't exist!");
                Console.ForegroundColor = ConsoleColor.Red;
                PublicationYear         = Helper.ReadYear("Reintroduce the year of publishing:");
                PublishingHouseName     = Helper.ReadString("Reintroduce publishing house name:");
            }

            authors = AuthorDAL.GetAuthorsForBook(bookName, PublicationYear, PublishingHouseName);
            return(authors);
        }
示例#2
0
        public void BorrowEdition()
        {
            string email = Helper.ReadString("Introduce user's email: ");

            while (!UserDAL.CheckUser(email))
            {
                Helper.DisplayError("\n User not found!");
                Console.ForegroundColor = ConsoleColor.Red;
                email = Helper.ReadString("\nReintroduce email: ");
            }

            string bookName = Helper.ReadString("Introduce the name of the book: ");

            while (!BookDAL.CheckBook(bookName))
            {
                Helper.DisplayError("\n Book not found!");
                Console.ForegroundColor = ConsoleColor.Red;
                bookName = Helper.ReadString("Introduce the name of the book: ");
            }

            int    publicationYear     = Helper.ReadYear("Introduce the year of publishing: ");
            string publishingHouseName = Helper.ReadString("Introduce publishing house name: ");

            while (!EditionDAL.CheckEdition(bookName, publishingHouseName, publicationYear))
            {
                Helper.DisplayError("\n Edition not found!");
                Console.ForegroundColor = ConsoleColor.Red;
                publicationYear         = Helper.ReadYear("Introduce the year of publishing: ");
                publishingHouseName     = Helper.ReadString("Introduce publishing house name: ");
            }

            string authorName = Helper.ReadString("Introduce the name of the author: ");
            Author author     = new Author(authorName);

            while (!AuthorDAL.CheckAuthor(author))
            {
                Helper.DisplayError("\n Wrong author!");
                Console.ForegroundColor = ConsoleColor.Red;
                authorName = Helper.ReadString("Introduce the name of the author: ");
                author     = new Author(authorName);
            }

            if (ValidBorrow(email, bookName, publishingHouseName, publicationYear))
            {
                Edition edition = new Edition()
                {
                    PublicationYear     = publicationYear,
                    PublishingHouseName = publishingHouseName,
                    Name = bookName,
                };

                int daysLeft = Helper.ReadInteger("Introduce the number of days of the borrow: ");

                DateTime endDate = DateTime.Now.AddDays(daysLeft);

                EditionDAL.BorrowEdition(email, edition, author, endDate);
                Console.WriteLine("\n Operation completed succesfully!");
            }
        }
示例#3
0
        public List <Domain> GetDomainsForBook()
        {
            string bookName = Helper.ReadString("Introduce the name of the book:");

            List <Domain> authors = null;

            while (!BookDAL.CheckBook(bookName))
            {
                Helper.DisplayError("\n Wrong book name!");
                Console.ForegroundColor = ConsoleColor.DarkBlue;
                bookName = Helper.ReadString("Reintroduce the name of the book:");
            }

            authors = BookDAL.GetDomainsForBook(bookName);

            return(authors);
        }
示例#4
0
        public void AddEdition()
        {
            string bookName = Helper.ReadString("\nInsert book name: ");
            string domain;

            if (BookDAL.CheckBook(bookName))
            {
                domain = string.Empty;
                ContinueAddEdition(bookName, domain);
            }
            else
            {
                domain = Helper.ReadString("\nIntroduce domain name: ");
                while (!DomainDAL.CheckDomain(domain))
                {
                    Helper.DisplayError("\n Inserted domain doesn't exist!");
                    Console.ForegroundColor = ConsoleColor.DarkCyan;
                    domain = Helper.ReadString("\nReintroduce domain name: ");
                }

                ContinueAddEdition(bookName, domain);
            }
        }
示例#5
0
        public void AddAuthorForEdition()
        {
            string bookName = Helper.ReadString("Introduce the name of the book: ");

            while (!BookDAL.CheckBook(bookName))
            {
                Helper.DisplayError("\n Wrong book name!");
                Console.ForegroundColor = ConsoleColor.Red;
                bookName = Helper.ReadString("\nReintroduce the name of the book: ");
            }

            int    publicationYear     = Helper.ReadYear("Introduce the year of publishing: ");
            string publishingHouseName = Helper.ReadString("Introduce publishing house name: ");

            while (!EditionDAL.CheckEdition(bookName, publishingHouseName, publicationYear))
            {
                Helper.DisplayError("\n Edition doesn't exist!");
                Console.ForegroundColor = ConsoleColor.Red;
                publicationYear         = Helper.ReadYear("Introduce the year of publishing: ");
                publishingHouseName     = Helper.ReadString("Introduce publishing house name: ");
            }

            string authorName = Helper.ReadString("Introduce the name of the author: ");

            Author author = new Author(authorName);

            Edition edition = new Edition()
            {
                PublicationYear     = publicationYear,
                PublishingHouseName = publishingHouseName,
                Name = bookName,
            };

            EditionDAL.AddAuthorForEdition(author, edition);
            Console.WriteLine("\n Operation completed succesfully!");
        }
示例#6
0
        public void AddDomainForBook()
        {
            string bookName = Helper.ReadString("Introduce the name of the book: ");

            while (!BookDAL.CheckBook(bookName))
            {
                Helper.DisplayError("\n Wrong book name!");
                Console.ForegroundColor = ConsoleColor.Red;
                bookName = Helper.ReadString("Reintroduce the name of the book: ");
            }

            string newDomainName = Helper.ReadString("Introduce the new domain: ");

            // aici verific ca noul domeniu sa nu contina deja cartea
            bool ok = true;

            foreach (Domain domain in BookDAL.GetDomainsForBook(bookName))
            {
                if (newDomainName.Equals(domain.DomainName))
                {
                    ok = false;
                    break;
                }
            }

            while (!DomainDAL.CheckDomain(newDomainName) || !ok || !ValidDomain(bookName, newDomainName))
            {
                if (!ValidDomain(bookName, newDomainName))
                {
                    Helper.DisplayError("\n The new domain is an ascendent of one of the existing domains of the book!");
                }
                else
                {
                    Helper.DisplayError("\n Invalid domain!");
                }

                Console.ForegroundColor = ConsoleColor.Red;
                newDomainName           = Helper.ReadString("Reintroduce the new domain: ");

                ok = true;
                foreach (Domain domain in BookDAL.GetDomainsForBook(bookName))
                {
                    if (newDomainName.Equals(domain.DomainName))
                    {
                        ok = false;
                        break;
                    }
                }
            }

            int size = BookDAL.GetDomainsForBook(bookName).Count;
            int DOM  = Helper.GetConfigData()["DOM"];

            if (size < DOM)
            {
                BookDAL.AddDomainForBook(newDomainName, bookName);
                Console.WriteLine("\n Operation completed succesfully!");
            }
            else
            {
                Helper.DisplayError("\nA book can belong to " + DOM + " domains. (DOM = " + DOM + ")");
            }
        }