Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            var applicationSettings = new ApplicationSettings();
            var bookRepo = new FileSystemStorage<Book>(applicationSettings);
            var customerRepo = new FileSystemStorage<Customer>(applicationSettings);

            var bookShopService = new BookShopService(bookRepo, customerRepo);

            #region data preparation
            var book = new Book
            {
                Price = 21.62,
                Title = "The Twelve : A Novel",
                Author = new Author
                {
                    Id = Guid.NewGuid(),
                    FirstName = "Justin",
                    LastName = "Cronin",
                    Rank = 23
                }
            };

            var customer = new Customer
            {
                Address = "Somewhere over the rainbow",
                CardNumber = "221234324",
                FirstName = "Clark",
                LastName = "Kent"
            };
            #endregion

            bookShopService.BuyOneBook(customer, book);
        }
Exemplo n.º 2
0
        public void BuyOneBook(Customer customer, Book book)
        {
            if (customer == null)
                throw new ArgumentNullException("customer");

            if (book == null)
                throw new ArgumentNullException("book");

            if (string.IsNullOrEmpty(customer.CardNumber))
                throw new InvalidCardNumberException();

            _bookRepository.Save(book);
            _customerRepository.Save(customer);
        }
        private void DataPreparation()
        {
            var book = new Book
            {
                Price = 21.62,
                Title = "The Twelve : A Novel",
                Author = new Author
                    {
                        Id = Guid.NewGuid(),
                        FirstName = "Justin",
                        LastName = "Cronin",
                        Rank = 23
                    }
            };

            var customer = new Customer
            {
                Address = "Somewhere over the rainbow",
                CardNumber = "221234324",
                FirstName = "Clark",
                LastName = "Kent"
            };

            _bookList.Add(book);
            _customerList.Add(customer);
        }