예제 #1
0
        public static BookEditionViewModel CreateFromBookEdition(BookEdition bookEdition,
                                                                 bool includeBook       = false,
                                                                 bool includeDimensions = false,
                                                                 bool includePublisher  = false)
        {
            var dto = new BookEditionViewModel
            {
                Isbn         = bookEdition.Isbn,
                PageCount    = bookEdition.PageCount,
                PrintDate    = bookEdition.PrintDate,
                CreationDate = bookEdition.CreationDate,
                CreatorId    = bookEdition.CreatorId
            };

            if (includeBook)
            {
                dto.Book = BookViewModel.CreateFromBook(bookEdition.Book);
            }

            if (includeDimensions)
            {
                dto.Dimensions = DimensionViewModel.CreateFromDimension(bookEdition.Dimensions);
            }

            if (includePublisher)
            {
                dto.Publisher = PublisherViewModel.CreateFromPublisher(bookEdition.Publisher);
            }

            return(dto);
        }
예제 #2
0
        public static DimensionViewModel CreateFromDimension(Dimension dimension, bool includeBookEditions = false)
        {
            var dto = new DimensionViewModel
            {
                Id           = dimension.Id,
                Width        = dimension.Width,
                Height       = dimension.Height,
                CreationDate = dimension.CreationDate,
                CreatorId    = dimension.CreatorId
            };

            if (includeBookEditions)
            {
                dto.BookEditions = BookEditionViewModel.CreateFromBookEditions(dimension.BookEditions);
            }

            return(dto);
        }