private void ContinueAddEdition(string bookName, string domain) { string publishingHouse = Helper.ReadString("\nInsert publishing house: "); int publicationYear = Helper.ReadYear("\nInsert publication year: "); while (EditionDAL.CheckEdition(bookName, publishingHouse, publicationYear)) { Helper.DisplayError("\n Edition already exist!"); Console.ForegroundColor = ConsoleColor.DarkCyan; publishingHouse = Helper.ReadString("\nReintroduce publishing house: "); publicationYear = Helper.ReadYear("\nReintroduce publication year: "); } string authorName = Helper.ReadString("\nInsert author name: "); int pageNr = Helper.ReadInteger("\nInsert page number:"); string bookType = Helper.ReadString("\nInsert book type: "); int initialStock = Helper.ReadInteger("\nInsert initial stock:"); Edition edition = new Edition(bookName, publishingHouse, pageNr, bookType, publicationYear, initialStock); Author author = new Author(authorName); EditionDAL.AddEdition(edition, author, domain); Console.WriteLine("\n Operation completed succesfully!"); }
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); }
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!"); } }
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!"); }