public ScarfOrder getCustomerCart(Customer customer) { ScarfOrder s; if (customer == null) { s = EmptyCart(); } else { s = _orderRepo.getCustomerCart(customer); if (s == null) { s = EmptyCart(customer); _orderRepo.add(s); } } return s; }
public void updateCustomer(Customer c) { _customerRepository.update(c); }
public ScarfOrder() { customer = new Customer(); Scarves = new HashSet<ScarfItem>(); }
public ScarfOrder EmptyCart(Customer customer = null) { return new ScarfOrder() { isCart = true, hasBeenPaidFor = false, customer = customer, hasShipped = false, Scarves = new List<ScarfItem>(0) }; }
public void RemoveFromCart(Customer c, long id) { ScarfOrder s = _orderRepo.getCustomerCart(c); List<ScarfItem> newScarves = new List<ScarfItem>(); foreach (var scarf in s.Scarves) { if (scarf.scarfId != id) { newScarves.Add(scarf); } } s.Scarves = newScarves; _orderRepo.update(s); }
public IEnumerable<ScarfOrder> getCustomerOrders(Customer customer) { List <ScarfOrder> s; if (customer == null) { s = new List<ScarfOrder>(); ScarfOrder emptyOrder = EmptyCart(); emptyOrder.isCart = false; s.Add(emptyOrder); } else { s = _orderRepo.getAll().Where(o => o.customer == customer && o.isCart == false) as List<ScarfOrder>; if(s == null || s.Count == 0) { s = new List<ScarfOrder>(0); ScarfOrder order = EmptyCart(customer); order.isCart = false; _orderRepo.add(order); s.Add(order); } } return s; }
public IEnumerable<ScarfOrder> getCustomerOrderHistory(Customer c) { List<ScarfOrder> orders = _orderRepo.getAll().Where(order => order.customer == c && order.isCart == false ).ToList(); return orders; }