public static LiteratureMetaViewModel ToLiteratureMetaViewModel(Library_Literature literature)
        {
            var totalCount = literature.Library_Book.Count(p => !p.IsDeleted);
            var freeCount = totalCount -
                            literature.Library_Book.Count(p => !p.IsDeleted && p.Library_ReservateBook.Any());

            return new LiteratureMetaViewModel()
            {
                Id = literature.Id,
                Author = literature.MainAuthor,
                ShortName = literature.ShortName,
                Year = literature.Year,
                TotalCount = totalCount,
                FreeCount = freeCount
            };
        }
示例#2
0
        public static LiteratureViewModel ToLiteratureViewModel(Library_Literature literature)
        {
            var books = literature.Library_Book.Where(p => !p.IsDeleted).Select(p => new BookOfLiteratureViewModel()
            {
                BookNumber = p.BookNumber,
                RowId = p.Id
            })
                .OrderBy(p => p.BookNumber)
                .ToList();

            return new LiteratureViewModel()
            {
                Id = literature.Id,
                FullName = literature.FullName,
                ShortName = literature.ShortName,
                Year = literature.Year,
                PublishingHouse = literature.PublishingHouse,
                MainAuthor = literature.MainAuthor,
                AdditionalAuthors = literature.AdditionalAuthors,
                Desqription = literature.Desqription,
                Books = books,
                FreeBooksCount = books.Count-literature.Library_Book.Count(p => p.Library_ReservateBook.Any())

            };
        }