예제 #1
0
 private static void AddCategories(AuthorBooksViewModel book, ICollection<Category> categories)
 {
     foreach (var category in categories)
     {
         book.Categories.Add(category.Name);
     }
 }
예제 #2
0
        public static AuthorBooksViewModel Create(Book book)
        {
            var bookView = new AuthorBooksViewModel
            {
                Title = book.Title,
                Description = book.Description,
                Edition = book.Edition,
                Price = book.Price,
                Copies = book.Copies,
                ReleaseDate = book.ReleaseDate,
                AgeRestriction = book.AgeRestriction,
                Categories = new List<string>(),

            };

            AddCategories(bookView, book.Categories);

            return bookView;
        }