public long Add(PubHouse t) { var id = (_items.Any() ? _items.Max(a => a.PubHouseId) : 0) + 1; t.PubHouseId = id; _items.Add(t); return(id); }
public BookModel(Book book, List <Author> thisBookAuthors, PubHouse pubHouse) { BookId = book.BookId; Title = book.Title; NumPages = book.NumPages; PublishYear = book.PublishYear; ISBN = book.ISBN; Illustration = book.Illustration; IllustrationUrl = book.Illustration != null ? $"data:image/jpeg;base64,{Convert.ToBase64String(book.Illustration)}" : ""; PubHouseId = book.PubHouseId; PubHouseName = pubHouse?.Name; Authors = thisBookAuthors.Select(q => q.AuthorId).ToList(); AuthorsNames = string.Join("; ", thisBookAuthors.Select(aa => $"{aa.LastName} {aa.FirstName}")); }
public void Update(PubHouse t) { throw new NotImplementedException(); }
private void Populate() { #region pubhouses var pros = new PubHouse { PubHouseId = 1, Name = "Просвещение" }; var ped = new PubHouse { PubHouseId = 2, Name = "Педагогическая книга" }; var clever = new PubHouse { PubHouseId = 3, Name = "Клевер" }; var act = new PubHouse { PubHouseId = 4, Name = "АСТ" }; var azb = new PubHouse { PubHouseId = 5, Name = "Азбука" }; PubHouses.Add(pros); PubHouses.Add(ped); PubHouses.Add(clever); PubHouses.Add(act); PubHouses.Add(azb); #endregion pubHouses #region authors var kamu = new Author { AuthorId = 1, FirstName = "Альбер", LastName = "Камю" }; var duma = new Author { AuthorId = 2, FirstName = "Александр", LastName = "Дюма" }; var gugo = new Author { AuthorId = 3, FirstName = "Виктор", LastName = "Гюго" }; var nizh = new Author { AuthorId = 4, FirstName = "Фридрих", LastName = "Ницше" }; var gess = new Author { AuthorId = 5, FirstName = "Герман", LastName = "Гессе" }; var akv = new Author { AuthorId = 6, FirstName = "Фома", LastName = "Аквинский" }; var kant = new Author { AuthorId = 7, FirstName = "Иммануил", LastName = "Кант" }; var mont = new Author { AuthorId = 8, FirstName = "Шарль", LastName = "Монтескье" }; var sart = new Author { AuthorId = 9, FirstName = "Жан-Поль", LastName = "Сартр" }; var frei = new Author { AuthorId = 10, FirstName = "Зигмунд", LastName = "Фрейд" }; var ark = new Author { AuthorId = 11, FirstName = "Аркадий", LastName = "Стругацкий" }; var bor = new Author { AuthorId = 12, FirstName = "Борис", LastName = "Стругацкий" }; Authors.Add(kamu); Authors.Add(duma); Authors.Add(gugo); Authors.Add(nizh); Authors.Add(gess); Authors.Add(akv); Authors.Add(kant); Authors.Add(mont); Authors.Add(sart); Authors.Add(frei); Authors.Add(ark); Authors.Add(bor); #endregion authors #region books var siz = new Book { BookId = 1, Title = "Миф о Сизифе", NumPages = 384, PubHouseId = pros.PubHouseId, ISBN = "978-5-17-083384-9", PublishYear = 2014 }; var sob = new Book { BookId = 2, Title = "Собор Парижской Богоматери", NumPages = 656, PubHouseId = clever.PubHouseId, ISBN = "978-5-699-38153-1", PublishYear = 2011 }; var zar = new Book { BookId = 3, Title = "Так говорил Заратустра", NumPages = 320, PubHouseId = azb.PubHouseId, ISBN = "978-5-17-082222-5", PublishYear = 2017 }; var three = new Book { BookId = 4, Title = "Три мушкетёра", NumPages = 958, PubHouseId = pros.PubHouseId, ISBN = "5-224-04981-4", PublishYear = 2005 }; var monday = new Book { BookId = 5, Title = "Понедельник начинается в субботу", NumPages = 320, PubHouseId = pros.PubHouseId, ISBN = "978-5-17-090334-4", PublishYear = 2017 }; var outlaw = new Book { BookId = 6, Title = "Отверженные", NumPages = 1248, PubHouseId = ped.PubHouseId, ISBN = "978-5-389-06864-3", PublishYear = 2014 }; Books.Add(siz); Books.Add(sob); Books.Add(zar); Books.Add(three); Books.Add(monday); Books.Add(outlaw); #endregion books #region book authors BookAuthors.Add(new BookAuthors { BookAuthorId = 1, BookId = siz.BookId, AuthorId = kamu.AuthorId }); BookAuthors.Add(new BookAuthors { BookAuthorId = 2, BookId = sob.BookId, AuthorId = gugo.AuthorId }); BookAuthors.Add(new BookAuthors { BookAuthorId = 3, BookId = zar.BookId, AuthorId = nizh.AuthorId }); BookAuthors.Add(new BookAuthors { BookAuthorId = 4, BookId = three.BookId, AuthorId = duma.AuthorId }); BookAuthors.Add(new BookAuthors { BookAuthorId = 5, BookId = outlaw.BookId, AuthorId = gugo.AuthorId }); BookAuthors.Add(new BookAuthors { BookAuthorId = 6, BookId = monday.BookId, AuthorId = ark.AuthorId }); BookAuthors.Add(new BookAuthors { BookAuthorId = 7, BookId = monday.BookId, AuthorId = bor.AuthorId }); #endregion book authors }