Пример #1
0
        private void btnUOW_Click(object sender, EventArgs e)
        {
            IUow uow = FactoryDalLayer <IUow> .Create("EfUOW");

            try
            {
                CustomerBase cust1 = new CustomerBase();
                cust1.CustomerType = "Admin";
                cust1.CustomerName = "Cust1";

                // Unit of work

                Idal.SetUnitWork(uow);
                Idal.Add(cust1); // In memory


                cust1 = new CustomerBase();
                cust1.CustomerType = "Admin";
                cust1.CustomerName = "Cust2";
                cust1.Email        = "*****@*****.**";
                IRepository <CustomerBase> dal1 = FactoryDalLayer <IRepository <CustomerBase> >
                                                  .Create(DalLayer.Text); // Unit

                dal1.SetUnitWork(uow);
                dal1.Add(cust1); // In memory

                uow.Committ();
            }
            catch (Exception ex)
            {
                uow.RollBack();
                MessageBox.Show(ex.Message.ToString());
            }
        }
        private void btnUOW_Click(object sender, EventArgs e)
        {
            IUow uow = FactoryDalLayer <IUow> .Create("EfUOW");

            try
            {
                CustomerBase cust1 = new CustomerBase();
                cust1.CustomerType = "Lead";
                cust1.CustomerName = "Cust1";

                // Unit of work

                Idal.SetUnitWork(uow);
                Idal.Add(cust1); // In memory


                cust1 = new CustomerBase();
                cust1.CustomerType = "Lead";
                cust1.CustomerName = "Cust2";
                cust1.Address      = "dzxcczxcxzcxzcsdhksjahdkjsahkdjhsakjdh kjashdkjahsd kjahskjdh kajsdhasd";
                IRepository <CustomerBase> dal1 = FactoryDalLayer <IRepository <CustomerBase> >
                                                  .Create(DalLayer.Text); // Unit

                dal1.SetUnitWork(uow);
                dal1.Add(cust1); // In memory

                uow.Committ();
            }
            catch (Exception ex)
            {
                uow.RollBack();
                MessageBox.Show(ex.Message.ToString());
            }
        }
Пример #3
0
        private void btnUOW_Click(object sender, EventArgs e)
        {
            IUow uow = FactoryDAL <IUow> .Create("EFUow");

            try
            {
                CustomerBase cust1 = new CustomerBase();
                cust1.CustomerType = "Lead";
                cust1.CustomerName = "Cust1";
                cust1.BillDate     = Convert.ToDateTime(txtBillingDate.Text);
                IRepository <CustomerBase> dal1 = FactoryDAL <IRepository <CustomerBase> > .Create(DalLayer.Text);

                dal1.SetUnitOfWork(uow);
                dal1.Add(cust1);

                CustomerBase cust2 = new CustomerBase();
                cust2.CustomerType = "Lead";
                cust2.CustomerName = "Cust2";
                cust2.BillDate     = Convert.ToDateTime(txtBillingDate.Text);
                cust2.Address      = "111111111111111111111111111111111111111111111111111111111111111";
                IRepository <CustomerBase> dal2 = FactoryDAL <IRepository <CustomerBase> > .Create(DalLayer.Text);

                dal2.SetUnitOfWork(uow);
                dal2.Add(cust2);

                uow.Commit();
            }
            catch (Exception ex)
            {
                uow.RollBack();
                MessageBox.Show(ex.Message);
            }
        }