예제 #1
0
        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;
        }
예제 #2
0
 public void updateCustomer(Customer c)
 {
     _customerRepository.update(c);
 }
예제 #3
0
 public ScarfOrder()
 {
     customer = new Customer();
     Scarves = new HashSet<ScarfItem>();
 }
예제 #4
0
 public ScarfOrder EmptyCart(Customer customer = null)
 {
     return new ScarfOrder() { isCart = true, hasBeenPaidFor = false, customer = customer, hasShipped = false, Scarves = new List<ScarfItem>(0) };
 }
예제 #5
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);
 }
예제 #6
0
        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;
        }
예제 #7
0
 public IEnumerable<ScarfOrder> getCustomerOrderHistory(Customer c)
 {
     List<ScarfOrder> orders =
         _orderRepo.getAll().Where(order => order.customer == c && order.isCart == false ).ToList();
     return orders;
 }