Exemplo n.º 1
0
        /// <summary>
        /// Create a new book
        /// </summary>
        /// <param name="author"> Autor's name of book</param>
        /// <param name="name">name of book</param>
        /// <param name="year">Year when the book was written</param>
        /// <returns>created book</returns>
        public ModelClass.Book AddBook(int author, string name, int year)
        {
            var newBook = new ModelClass.Book()
            {
                ItemId = GenId(Model.Books),
                Author = author,
                Name   = name,
                Year   = year
            };

            Model.Books.Add(newBook);
            GetAuthor(author).BooksWritten.Add(newBook.ItemId);
            return(newBook);
        }
Exemplo n.º 2
0
        protected string DisplayBook(ModelClass.Book book)
        {
            var s = new StringBuilder();

            s.AppendLine("id: " + book.ItemId.ToString());
            s.AppendLine("Название: " + book.Name);
            s.AppendLine("Год: " + book.Year.ToString());
            s.AppendLine("Автор: " + DisplayAuthorShort(controller.GetAuthor(book.Author)));
            s.AppendLine("Экземпляры (" + book.BookCopies.Count.ToString() + "): ");
            foreach (var copyid in book.BookCopies)
            {
                s.AppendLine(DisplayCopyShort(controller.GetCopy(copyid)));
            }
            return(s.ToString());
        }
Exemplo n.º 3
0
 protected string DisplayBookShort(ModelClass.Book book)
 {
     return(book.Name + " " + book.Year.ToString());
 }