public CustomerRepresentation login(String customerName, String customerPassword) { Set<Customer> customers = new HashSet<Customer>(); customers = CustomerDAO.getAllCustomers(); for (Customer c : customers) { if (c.getName().equals(customerName) && c.getPassword().equals(customerPassword)) { return getCustomer(String.valueOf(c.getID())); } } return null; }
public CustomerRepresentation getCustomer(String id) { Customer c = CustomerDAO.retrieveCustomer(Long.parseLong(id)); CustomerRepresentation customerRep = new CustomerRepresentation(); customerRep.setID(c.getID()); customerRep.setCustomerName(c.getName()); customerRep.setCustomerAddress(c.getAddress()); customerRep.setCustomerBillingInfoID(c.getBillingInfo().getID()); setLinks(customerRep); return customerRep; }
public Set<CustomerRepresentation> getCustomers() { Set<Customer> customers = new HashSet<Customer>(); Set<CustomerRepresentation> customerReps = new HashSet<CustomerRepresentation>(); customers = CustomerDAO.getAllCustomers(); for (Customer c : customers) { CustomerRepresentation customerRep = new CustomerRepresentation(); customerRep.setID(c.getID()); customerRep.setCustomerName(c.getName()); customerRep.setCustomerAddress(c.getAddress()); customerRep.setCustomerBillingInfoID(c.getBillingInfo().getID()); customerReps.add(customerRep); setLinks(customerRep); } return customerReps; }
public CustomerRepresentation updateCustomerAddress(String customerId, String addr) { Customer c = CustomerDAO.retrieveCustomer(Long.parseLong(customerId)); c.setAddress(addr); CustomerDAO.addCustomer(c); return this.getCustomer(customerId); }
public CustomerRepresentation updateCustomerPassword(String customerId, String pass) { Customer c = CustomerDAO.retrieveCustomer(Long.parseLong(customerId)); c.setPassword(pass); CustomerDAO.addCustomer(c); return this.getCustomer(customerId); }
public String deleteCustomer(String id) { CustomerDAO.deleteCustomer(CustomerDAO.retrieveCustomer(Long.parseLong(id))); return "OK"; }
public String createCustomer(CustomerRequest customerRequest) { Customer c = CustomerDAO.addNewCustomer( customerRequest.getCustomerName(), customerRequest.getCustomerPass()); return "OK"; }