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());
            }
        }
예제 #2
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());
            }
        }
 public void PostProject([FromBody] ProjectBase ObjProjectToAdd)
 {
     if (ObjProjectToAdd.ProjectName != "")
     {
         _ObjectOfProjectBusinessLogic.AddNewProject(ObjProjectToAdd);
         _ObjectUnitOfWork.Committ();
     }
 }
 public void PostPerson([FromBody] PersonBase ObjPersonToAdd)
 {
     if (ObjPersonToAdd.FirstName != "" && ObjPersonToAdd.LastName != "")
     {
         _ObjectOfPersonBusinessLogic.AddNewPerson(ObjPersonToAdd);
         _ObjectUnitOfWork.Committ();
     }
 }
예제 #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            //validate first
            customer.Validate();

            IRepository <CustomerBase> dal = null;

            dal = FactoryCustomer.CreateDAL("CustomerDAL");

            //get customer base instance using factory
            CustomerBase customerBase = new CustomerBase();

            //get customer base instance using factory
            IUow unitOfWork = (IUow)FactoryCustomer.CreateUOW();

            //Map
            customerBase.Address      = customer.Address;
            customerBase.BillAmount   = customer.BillAmount;
            customerBase.BillDate     = customer.BillDate;
            customerBase.Address      = customer.Address;
            customerBase.PhoneNumber  = customer.PhoneNumber;
            customerBase.CustomerName = customer.CustomerName;

            try
            {
                dal.SetUnitOfWork(unitOfWork);
                dal.Add(customerBase);
                //dal.Save(customerBase);
                unitOfWork.Committ();   //use unit-of-work design pattern
                dataGridView1.DataSource = LoadGrid();
            }
            catch
            {
                unitOfWork.Rollback();
            }
        }
예제 #6
0
 public void PostPersonToProject([FromBody] ProjectPersonBase ObjProjectPersonToAdd)
 {
     _ObjectOfProjectPersonBusinessLogic.AddNewPersonToProject(ObjProjectPersonToAdd);
     _ObjectUnitOfWork.Committ(); // final physical commit here
 }