Exemplo n.º 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();
        }
Exemplo n.º 2
0
        public void Delete(int id)
        {
            var customer = CustomerCache.Find(Customer => Customer.ID == id);

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