Пример #1
0
 public int CommitChanges()
 {
     // using (Uow)
     {
         return(Uow.CommitChanges());
     }
 }
Пример #2
0
 private void btnRemove_Click(object sender, EventArgs e)
 {
     try
     {
         try
         {
             Model.Internal.BoardComputer boardComputer = (Model.Internal.BoardComputer)gdvBoardComputer.GetRow(this.gdvBoardComputer.FocusedRowHandle);
             if (boardComputer == null)
             {
                 return;
             }
             if (DevExpress.XtraEditors.XtraMessageBox.Show(this.LookAndFeel, "Bent u zeker dat u de boordcomputer wilt verwijderen?", "Verwijderen?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
                                                            MessageBoxDefaultButton.Button3) == DialogResult.Yes)
             {
                 boardComputer.Delete();
                 Uow.CommitChanges();
                 FindAll();
             }
         }
         catch (System.Exception exception1)
         {
             System.Exception thisException = exception1;
             Management.ShowException(thisException);
         }
     }
     catch (System.Exception exception1)
     {
         System.Exception thisException = exception1;
         Management.ShowException(thisException);
     }
 }
Пример #3
0
 private void tileDocument_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     try
     {
         if (e.Button == System.Windows.Forms.MouseButtons.Right)
         {
             DocumentNodeOrLink dnol = new DocumentNodeOrLink(iclExtraLarge);
             dnol.ShowDialog(this);
             if (dnol.DialogResult == DialogResult.OK)
             {
                 TIS.Model.Internal.Document.DocNode newNode = new TIS.Model.Internal.Document.DocNode(Uow);
                 newNode.ParentDocNode = _selectedNode;
                 newNode.Name          = dnol.NodeName;
                 //newNode.DocTreeDisplay = _docTree;
                 newNode.ImageIndex = dnol.Index;
                 if (dnol.isLink)
                 {
                     Model.Internal.Document.Document document = new Model.Internal.Document.Document(Uow);
                     document.Name           = dnol.Url;
                     document.DocTypeDisplay = Enumeration.Document.DocumentType.Link;
                     document.DocNode        = newNode;
                     newNode.Document        = document;
                 }
                 Uow.CommitChanges();
                 SelectNode(_selectedNode);
             }
         }
     }
     catch (Exception exception1)
     {
         System.Exception thisException = exception1;
         Management.ShowException(thisException);
     }
 }
        public void If_ServiceRateDiscount_does_NOT_exist_for_Customer_ServiceType_DefaultRate_should_be_applied()
        {
            const int defaultRate = 10;

            // Arrange
            var customer = new Customer(Uow)
            {
                DateOfBirth = new DateTime(1990, 1, 1)
            };
            var serviceType = new ServiceType(Uow)
            {
                DefaultRate = defaultRate
            };

            Uow.CommitChanges();

            // Act
            var transaction = new Transaction(Uow)
            {
                Customer = customer, ServiceType = serviceType
            };

            // Assert
            transaction.TransactionPrice.ShouldBe(defaultRate);
        }
Пример #5
0
        public Supplier UpdateSupplier(Supplier value)
        {
            var entity = Uow.SupplierRepository.Get(value);

            if (entity != null)
            {
                entity.CompanyName  = value.CompanyName;
                entity.ContactName  = value.ContactName;
                entity.ContactTitle = value.ContactTitle;
                entity.Address      = value.Address;
                entity.City         = value.City;
                entity.Region       = value.Region;
                entity.PostalCode   = value.PostalCode;
                entity.Country      = value.Country;
                entity.Phone        = value.Phone;
                entity.Fax          = value.Fax;
                entity.HomePage     = value.HomePage;

                Uow.SupplierRepository.Update(entity);

                Uow.CommitChanges();
            }

            return(entity);
        }
        public void If_ServiceRateDiscount_DOES_exist_for_Customer_and_ServiceRate_it_should_be_assigned()
        {
            const int defaultRate  = 15;
            const int adjustedRate = 10;

            // Arrange
            var customer = new Customer(Uow)
            {
                DateOfBirth = new DateTime(1990, 1, 1)
            };
            var serviceType = new ServiceType(Uow)
            {
                DefaultRate = defaultRate
            };
            var serviceRateDiscount = new ServiceRateDiscount(Uow)
            {
                ServiceType = serviceType, Customer = customer, AdjustedRate = adjustedRate
            };

            Uow.CommitChanges();

            // Act
            var transaction = new Transaction(Uow)
            {
                Customer = customer, ServiceType = serviceType
            };

            // Assert
            transaction.ServiceRateDiscount.ShouldBe(serviceRateDiscount);
            transaction.TransactionPrice.ShouldBe(adjustedRate);
        }
        public void When_GetSingleServiceRateDiscountResult_and_more_than_1_discount_DOES_exist_it_should_return_none()
        {
            const int defaultRate  = 15;
            const int adjustedRate = 10;

            // Arrange
            var customer = new Customer(Uow)
            {
                DateOfBirth = new DateTime(1990, 1, 1)
            };
            var serviceType = new ServiceType(Uow)
            {
                DefaultRate = defaultRate
            };

            // ReSharper disable once ObjectCreationAsStatement
            new ServiceRateDiscount(Uow)
            {
                ServiceType = serviceType, Customer = customer, AdjustedRate = adjustedRate
            };
            // ReSharper disable once ObjectCreationAsStatement
            new ServiceRateDiscount(Uow)
            {
                ServiceType = serviceType, Customer = customer, AdjustedRate = adjustedRate
            };
            Uow.CommitChanges();

            // Act & Assert
            GetSingleServiceRateDiscountResult(Uow, serviceType, customer).IsFailure.ShouldBeTrue();
        }
        public Region CreateRegion(Region entity)
        {
            Uow.RegionRepository.Add(entity);

            Uow.CommitChanges();

            return(entity);
        }
Пример #9
0
        public Supplier CreateSupplier(Supplier entity)
        {
            Uow.SupplierRepository.Add(entity);

            Uow.CommitChanges();

            return(entity);
        }
        public Product CreateProduct(Product entity)
        {
            Uow.ProductRepository.Add(entity);

            Uow.CommitChanges();

            return(entity);
        }
        public Shipper CreateShipper(Shipper entity)
        {
            Uow.ShipperRepository.Add(entity);

            Uow.CommitChanges();

            return(entity);
        }
        public Category CreateCategory(Category entity)
        {
            Uow.CategoryRepository.Add(entity);

            Uow.CommitChanges();

            return(entity);
        }
Пример #13
0
 /// <summary>
 /// Delete then commit
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public bool Delete(object id)
 {
     // using (Uow)
     {
         var repository = Uow.GetRepository();
         repository.Delete(id);
         return(Uow.CommitChanges() > 0);
     }
 }
Пример #14
0
 /// <summary>
 /// Delete then commit
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public bool Delete(TEntity entity)
 {
     //using (Uow)
     {
         var repository = Uow.GetRepository();
         repository.Delete(entity);
         return(Uow.CommitChanges() > 0);
     }
 }
Пример #15
0
        public void When_creating_a_Customer_contract_should_get_created()
        {
            // Arrange & Act
            var customer = new Customer(Uow);

            Uow.CommitChanges();

            // Assert
            GetOne <Customer>(c => c.ID == customer.ID).Contracts.Count.ShouldBe(1);
        }
        public Region DeleteRegion(Region value)
        {
            var entity = Uow.RegionRepository.Get(value);

            if (entity != null)
            {
                Uow.RegionRepository.Remove(entity);

                Uow.CommitChanges();
            }

            return(entity);
        }
Пример #17
0
        public Customer DeleteCustomer(Customer value)
        {
            var entity = Uow.CustomerRepository.Get(value);

            if (entity != null)
            {
                Uow.CustomerRepository.Remove(entity);

                Uow.CommitChanges();
            }

            return(entity);
        }
Пример #18
0
        public Supplier DeleteSupplier(Supplier value)
        {
            var entity = Uow.SupplierRepository.Get(value);

            if (entity != null)
            {
                Uow.SupplierRepository.Remove(entity);

                Uow.CommitChanges();
            }

            return(entity);
        }
        public Category DeleteCategory(Category value)
        {
            var entity = Uow.CategoryRepository.Get(value);

            if (entity != null)
            {
                Uow.CategoryRepository.Remove(entity);

                Uow.CommitChanges();
            }

            return(entity);
        }
        public Product DeleteProduct(Product value)
        {
            var entity = Uow.ProductRepository.Get(value);

            if (entity != null)
            {
                Uow.ProductRepository.Remove(entity);

                Uow.CommitChanges();
            }

            return(entity);
        }
Пример #21
0
        public Customer CreateCustomer(Customer entity)
        {
            if (entity != null && !String.IsNullOrEmpty(entity.CustomerID))
            {
                entity.CustomerID = entity.CompanyName.Substring(0, 5).ToUpper();
            }

            Uow.CustomerRepository.Add(entity);

            Uow.CommitChanges();

            return(entity);
        }
        public Region UpdateRegion(Region value)
        {
            var entity = Uow.RegionRepository.Get(value);

            if (entity != null)
            {
                entity.RegionDescription = value.RegionDescription;

                Uow.RegionRepository.Update(entity);

                Uow.CommitChanges();
            }

            return(entity);
        }
        public Shipper UpdateShipper(Shipper value)
        {
            var entity = Uow.ShipperRepository.Get(value);

            if (entity != null)
            {
                entity.CompanyName = value.CompanyName;
                entity.Phone       = value.Phone;

                Uow.ShipperRepository.Update(entity);

                Uow.CommitChanges();
            }

            return(entity);
        }
Пример #24
0
        public void When_saving_an_existing_customer_new_Contract_should_NOT_be_added()
        {
            // Arrange
            var customer = new Customer(Uow);

            Uow.CommitChanges();

            // Act
            var anotherUow       = GetUow();
            var existingCustomer = anotherUow.GetObjectByKey <Customer>(customer.ID);

            existingCustomer.DateOfBirth = new DateTime(1983, 1, 1);
            anotherUow.CommitChanges();

            // Assert
            GetReloaded(GetOne <Customer>(c => c.ID == customer.ID)).Contracts.Count.ShouldBe(1);
        }
        public Category UpdateCategory(Category value)
        {
            var entity = Uow.CategoryRepository.Get(value);

            if (entity != null)
            {
                entity.CategoryName = value.CategoryName;
                entity.Description  = value.Description;
                entity.Picture      = value.Picture;

                Uow.CategoryRepository.Update(entity);

                Uow.CommitChanges();
            }

            return(entity);
        }
        public void When_GetSingleServiceRateDiscountResult_and_discount_does_NOT_exist()
        {
            const int defaultRate = 15;

            // Arrange
            var customer = new Customer(Uow)
            {
                DateOfBirth = new DateTime(1990, 1, 1)
            };
            var serviceType = new ServiceType(Uow)
            {
                DefaultRate = defaultRate
            };

            Uow.CommitChanges();

            // Act & Assert
            GetSingleServiceRateDiscountResult(Uow, serviceType, customer).IsFailure.ShouldBeTrue();
        }
        public Product UpdateProduct(Product value)
        {
            var entity = Uow.ProductRepository.Get(value);

            if (entity != null)
            {
                entity.ProductName     = value.ProductName;
                entity.SupplierID      = value.SupplierID;
                entity.CategoryID      = value.CategoryID;
                entity.QuantityPerUnit = value.QuantityPerUnit;
                entity.UnitPrice       = value.UnitPrice;

                Uow.ProductRepository.Update(entity);

                Uow.CommitChanges();
            }

            return(entity);
        }
        public Shipper DeleteShipper(Shipper value)
        {
            var entity = Uow.ShipperRepository.Get(value);

            if (entity != null)
            {
                var relatedOrders = GetOrdersByShipVia(entity.ShipperID);

                if (relatedOrders.Count() > 0)
                {
                    throw new ForeignKeyDependencyException(String.Format("Unable to delete shipper with id: '{0}', because has orders associated.", entity.ShipperID));
                }

                Uow.ShipperRepository.Remove(entity);

                Uow.CommitChanges();
            }

            return(entity);
        }
Пример #29
0
 private void tileDocument_DragDrop(object sender, DragEventArgs e)
 {
     try
     {
         string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
         Model.Internal.Document.Document document = new Model.Internal.Document.Document(Uow);
         foreach (string file in FileList)
         {
             if (!System.IO.Directory.Exists(file))
             {
                 document.ReadFile(file);
                 document.Name           = file.Substring(file.LastIndexOf('\\') + 1);
                 document.DocTypeDisplay = Enumeration.Document.DocumentType.Document;
                 TIS.Model.Internal.Document.DocNode newNode = new TIS.Model.Internal.Document.DocNode(Uow);
                 newNode.Document      = document;
                 newNode.ParentDocNode = _selectedNode;
                 newNode.Name          = document.Name;
                 //newNode.DocTreeDisplay = _docTree;
                 newNode.ImageIndex = -1;
                 DocumentFile df = new DocumentFile(iclExtraLarge, document.Name);
                 df.ShowDialog(this);
                 if (df.DialogResult == DialogResult.OK)
                 {
                     newNode.ImageIndex = df.Index >= iclExtraLarge.Images.Count ? -1 : df.Index;
                     newNode.Name       = df.DocName;
                     Uow.CommitChanges();
                 }
                 //this.Uow = new UnitOfWork();
             }
         }
         SelectNode(_selectedNode);
     }
     catch (Exception exception1)
     {
         System.Exception thisException = exception1;
         Management.ShowException(thisException);
     }
 }
        public void When_GetSingleServiceRateDiscountResult_and_discount_DOES_exist_it_should_return_it()
        {
            const int defaultRate  = 15;
            const int adjustedRate = 10;

            // Arrange
            var customer = new Customer(Uow)
            {
                DateOfBirth = new DateTime(1990, 1, 1)
            };
            var serviceType = new ServiceType(Uow)
            {
                DefaultRate = defaultRate
            };
            var serviceRateDiscount = new ServiceRateDiscount(Uow)
            {
                ServiceType = serviceType, Customer = customer, AdjustedRate = adjustedRate
            };

            Uow.CommitChanges();

            // Act & Assert
            GetSingleServiceRateDiscountResult(Uow, serviceType, customer).Value.ShouldBe(serviceRateDiscount);
        }