Beispiel #1
0
        public static List <BookWithEvents> CreateDummyBooksWithEvents(int numBooks = 10, bool stepByYears = false)
        {
            var result       = new List <BookWithEvents>();
            var commonAuthor = new AuthorWithEvents("CommonAuthor", null);

            for (int i = 0; i < numBooks; i++)
            {
                var book = BookWithEvents.CreateBook
                           (
                    $"Book{i:D4} Title",
                    $"Book{i:D4} Description",
                    stepByYears ? DummyBookStartDate.AddYears(i) : DummyBookStartDate.AddDays(i),
                    "Publisher",
                    (short)(i + 1),
                    $"Image{i:D4}",
                    new[] { new AuthorWithEvents($"Author{i:D4}", null), commonAuthor }
                           ).Result;
                for (int j = 0; j < i; j++)
                {
                    book.AddReview((j % 5) + 1, null, j.ToString());
                }

                result.Add(book);
            }

            return(result);
        }
 public AuthorNameUpdatedEvent(AuthorWithEvents changedAuthor)
 {
     ChangedAuthor = changedAuthor;
 }
        public static List <BookWithEvents> CreateFourBooks()
        {
            var martinFowler = new AuthorWithEvents("Martin Fowler", null);

            var books = new List <BookWithEvents>();

            var book1 = BookWithEvents.CreateBook
                        (
                "Refactoring",
                "Improving the design of existing code",
                new DateTime(1999, 7, 8),
                null,
                40,
                null,
                new[] { martinFowler }
                        ).Result;

            books.Add(book1);

            var book2 = BookWithEvents.CreateBook
                        (
                "Patterns of Enterprise Application Architecture",
                "Written in direct response to the stiff challenges",
                new DateTime(2002, 11, 15),
                null,
                53,
                null,
                new [] { martinFowler }
                        ).Result;

            books.Add(book2);

            var book3 = BookWithEvents.CreateBook
                        (
                "Domain-Driven Design",
                "Linking business needs to software design",
                new DateTime(2003, 8, 30),
                null,
                56,
                null,
                new[] { new AuthorWithEvents("Eric Evans", null) }
                        ).Result;

            books.Add(book3);

            var book4 = BookWithEvents.CreateBook
                        (
                "Quantum Networking",
                "Entangled quantum networking provides faster-than-light data communications",
                new DateTime(2057, 1, 1),
                "Future Published",
                220,
                null,
                new[] { new AuthorWithEvents("Future Person", null) }
                        ).Result;

            book4.AddReview(5,
                            "I look forward to reading this book, if I am still alive!", "Jon P Smith");
            book4.AddReview(5,
                            "I write this book if I was still alive!", "Albert Einstein"); book4.AddPromotion(219, "Save $1 if you order 40 years ahead!");
            book4.AddPromotion(219, "Save 1$ by buying 40 years ahead");

            books.Add(book4);

            return(books);
        }