예제 #1
0
        public void Save()
        {
            System.Diagnostics.Trace.WriteLine("Starting to save New Customer");

            //foreach (Customer c in this.context.Customers)
            //{
            //    this.context.Customers.Remove(c);
            //}
            foreach (Customer c in CustomerCache)
            {
                if (this.context.Customers.Find(c.ID) == null)
                {
                    this.context.Customers.Add(c);
                }
            }

            foreach (Customer c in this.context.Customers)
            {
                if (CustomerCache.Find(Customer => Customer.ID == c.ID) == null)
                {
                    this.context.Customers.Remove(c);
                }
            }

            this.context.SaveChanges();
        }
예제 #2
0
        public void Delete(int id)
        {
            var customer = CustomerCache.Find(Customer => Customer.ID == id);

            CustomerCache.Remove(customer);
            //this.context.Customers.Remove(customer);
        }