Package com.bookstore.domain.model

Examples of com.bookstore.domain.model.Customer


    customers = new ArrayList<Customer>();
   
    // Add the fake data
   
    // CUSTOMER 1
    Customer customer1 = new Customer();
    customer1.setId("0");
    customer1.setFirstName("Eric");
    customer1.setLastName("Burns");
   
    customer1.setUsername("ericburns");
    customer1.setPassword("password");
   
    List<Address> c1a = new ArrayList<Address>();
    c1a.add(mat.addresses.get(0));
    customer1.setAddresses(c1a);
   
    List<CreditCard> c1cc = new ArrayList<CreditCard>();
    c1cc.add(mcct.creditCards.get(0));
    c1cc.add(mcct.creditCards.get(1));
    customer1.setCreditCards(c1cc);
   
    List<Book> c1b = new ArrayList<Book>();
    c1b.add(mbt.books.get(0));
    c1b.add(mbt.books.get(1));
    c1b.add(mbt.books.get(2));
    customer1.setBooks(c1b);
   
    // CUSTOMER 2
    Customer customer2 = new Customer();
    customer2.setId("1");
    customer2.setFirstName("Leroy");
    customer2.setLastName("Jenkins");
   
    customer2.setUsername("ljenkins");
    customer2.setPassword("password");
   
    List<Address> c2a = new ArrayList<Address>();
    c2a.add(mat.addresses.get(1));
    customer2.setAddresses(c2a);
   
    List<CreditCard> c2cc = new ArrayList<CreditCard>();
    c2cc.add(mcct.creditCards.get(3));
    customer2.setCreditCards(c2cc);
   
    List<Book> c2b = new ArrayList<Book>();
    c2b.add(mbt.books.get(4));
    c2b.add(mbt.books.get(1));
    c2b.add(mbt.books.get(7));
    customer2.setBooks(c2b);
   
    // CUSTOMER 3
    Customer customer3 = new Customer();
    customer3.setId("2");
    customer3.setFirstName("Thomas");
    customer3.setLastName("Cobal");
   
    customer3.setUsername("t_co");
    customer3.setPassword("password");
   
    List<Address> c3a = new ArrayList<Address>();
    c3a.add(mat.addresses.get(2));
    customer3.setAddresses(c3a);
   
    List<CreditCard> c3cc = new ArrayList<CreditCard>();
    c3cc.add(mcct.creditCards.get(2));
    customer3.setCreditCards(c3cc);
   
    List<Book> c3b = new ArrayList<Book>();
    c3b.add(mbt.books.get(3));
    c3b.add(mbt.books.get(5));
    c3b.add(mbt.books.get(6));
    c3b.add(mbt.books.get(8));
    customer3.setBooks(c3b);
   
    customers.addAll(Arrays.asList(customer1, customer2, customer3));
  }
View Full Code Here


   */
  public Customer addCustomer(String firstName, String lastName, List<Address> addresses,
                List<CreditCard> creditCards, List<Book> books) {
   
    // Create the new book.
    Customer customer = new Customer();
    customer.setId(String.valueOf(db.customers.size()));
    customer.setFirstName(firstName);
    customer.setLastName(lastName);
    customer.setAddresses(addresses);
    customer.setCreditCards(creditCards);
    customer.setBooks(books);
   
    // Add the new book.
    db.customers.add(customer);
   
    // Return the new book.
View Full Code Here

   * @param creditCards
   */
  public void updateCustomer(String id, String firstName, String lastName, List<Address> addresses,
                 List<CreditCard> creditCards, List<Book> books) {
   
    Customer customer = db.customers.get(Integer.parseInt(id));
    customer.setFirstName(firstName);
    customer.setLastName(lastName);
    customer.setAddresses(addresses);
    customer.setCreditCards(creditCards);
    customer.setBooks(books);
  }
View Full Code Here

   * Create a representation of a single customer.
   * @param id
   * @return
   */
  public CustomerRepresentation getCustomer(String id) {
    Customer customer = customerDao.getCustomer(id);
   
    CustomerRepresentation custRep = new CustomerRepresentation();
    custRep.setId(customer.getId());
    custRep.setFirstName(customer.getFirstName());
    custRep.setLastName(customer.getLastName());
    custRep.setAddresses(customer.getAddresses());
    custRep.setCreditCards(customer.getCreditCards());
    custRep.setBooks(customer.getBooks());
   
    return custRep;
  }
View Full Code Here

   * @return
   */
  public CustomerRepresentation createCustomer(String firstName, String lastName,
                         List<Address> addresses, List<CreditCard> creditCards,
                         List<Book> books) {
    Customer customer = customerDao.addCustomer(firstName, lastName, addresses, creditCards, books);
   
    CustomerRepresentation custRep = new CustomerRepresentation();
    custRep.setId(customer.getId());
    custRep.setFirstName(customer.getFirstName());
    custRep.setLastName(customer.getLastName());
    custRep.setAddresses(customer.getAddresses());
    custRep.setCreditCards(customer.getCreditCards());
    custRep.setBooks(customer.getBooks());
   
    return custRep;
  }
View Full Code Here

  public OrderRepresentation createOrder(String customerId) {
   
    // If an open order exists, send back that one
    //  If it doesn't, send back a new, empty one
    Order order = orderDao.getCustomerCurrentOrder(customerId);
    Customer customer = customerDao.getCustomer(customerId);
   
    if (order == null) {
      order = orderDao.addOrder(customer, customer.getAddresses().get(0),
          customer.getAddresses().get(0), customer.getCreditCards().get(0),
          shippingCompanyDao.getShippingCompanies().get(0), new ArrayList<Line>(),
          false, "Open");
    }
   
    return createRepresentation(order);
View Full Code Here

      }
      if (!exists) {
        order.addBook(book, 1);
      }
    } else {
      Customer customer = customerDao.getCustomer(customerId);
      order = orderDao.addOrder(customer, customer.getAddresses().get(0),
          customer.getAddresses().get(0), customer.getCreditCards().get(0),
          shippingCompanyDao.getShippingCompanies().get(0), new ArrayList<Line>(),
          false, "Open");
      order.addBook(book, 1);
    }
View Full Code Here

TOP

Related Classes of com.bookstore.domain.model.Customer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.