using ProjectLibrary.Forms; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProjectLibrary.Entites { public class Library { public int Id { get; private set; } [DisplayName("Название")] public string Name { get; private set; } = string.Empty; [DisplayName("Адрес")] public string Address { get; private set; } = string.Empty; [Browsable(false)] public IEnumerable BookLibrary { get; private set; } [DisplayName("Перечень книг в библиотеке")] public string ListBookInLibrary => BookLibrary != null ? string.Join("; ", BookLibrary.Select(x => $"{x.BookID},{x.Count}")): string.Empty; public static Library CreateEntity(int id, string name, string address, IEnumerable bookLibrary) { return new Library { Id = id, Name = name ?? string.Empty, Address = address ?? string.Empty, BookLibrary = bookLibrary }; } public void SetLibraryForBook(IEnumerable book_Library) { if (book_Library != null && book_Library.Any()) { BookLibrary = book_Library; } } } }