Esempio n. 1
0
        //public ICustomersRepository GetCustomerRepository()
        //{

        //    if (customerRepository == null)
        //    {
        //        customerRepository = new CustomersRepository(entities);
        //    }

        //    return customerRepository;

        //}

        //public IPeopleRepository GetPeopleRepository()
        //{

        //    if (peopleRepository == null)
        //    {
        //        peopleRepository = new PeopleRepository(entities);
        //    }
        //    return peopleRepository;

        //}

        //public IStoreRepository GetStoreRepository()
        //{
        //    if (storeRepository == null)
        //    {
        //        storeRepository = new StoreRepository(entities);
        //    }
        //    return storeRepository;
        //}



        public void SaveChanges()
        {
            try
            {
                if (this.transactionOpen)
                {
                    OpenTransaction();
                }

                entities.SaveChanges();

                if (this.transactionOpen)
                {
                    this.transaction.Commit();
                    this.transaction.Dispose();
                }
            }
            catch (Exception e)
            {
                //TODO log in the system
                if (this.transactionOpen)
                {
                    this.transaction.Rollback();
                }

                //throw controllated exception after the rollback
                throw e;
            }
        }