private static void AddCategories(AuthorBooksViewModel book, ICollection<Category> categories) { foreach (var category in categories) { book.Categories.Add(category.Name); } }
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; }