Example #1
0
        public static void AddNew(Customer c)
        {
            if (c.ID != 0)
            {
                throw new ApplicationException("Customer should not have id assigned yet");
            }

            int maxID = __customers.Max(cust => cust.ID);
            c.ID = maxID + 1;
            __customers.Add(c);
        }
Example #2
0
        public static void UpdateCustomer(Customer c)
        {
            Customer current = __customers.Where(t => t.ID == c.ID).First();
            if (current != null)
            {
                __customers.Remove(current);
                __customers.Add(c);
            }
            else
            {
                throw new ApplicationException("Customer " + c.ID + " does not exist");
            }

        }
Example #3
0
        public static void UpdateCustomer(Customer c)
        {
        	Customer current = __customers.Find(delegate(Customer t) { return t.ID == c.ID; });
            if (current != null)
            {
                __customers.Remove(current);
                __customers.Add(c);
            }
            else
            {
                throw new ApplicationException("Customer " + c.ID + " does not exist");
            }

        }