Пример #1
0
 public bool CheckIfProductIsActive()
 {
     if (ProductVersions.Count != 0)
     {
         return(ProductVersions.Last().IsActive);
     }
     else
     {
         return(false);
     }
 }
Пример #2
0
        public void RemoveProductUnit(Unit unitToRemove)
        {
            ProductVersion newVersion, previousVersion;

            previousVersion = ProductVersions.Last();

            if (previousVersion.Units.Contains(unitToRemove))
            {
                //Copying data from previous to new
                newVersion = DublicateProductVersion(previousVersion);

                //Adding the change
                newVersion.Units.Remove(unitToRemove);
                this.ProductVersions.Add(newVersion);
                repository.UpdateProductVersionList(this);
            }
            else
            {
                throw new UnitAlreadyRemovedException();
            }
        }
Пример #3
0
        public void AddProductUnit(Unit unitToAdd)
        {
            ProductVersion newVersion, previousVersion;

            previousVersion = ProductVersions.Last();

            if (!previousVersion.Units.Contains(unitToAdd))
            {
                //Copying data from previous to new
                newVersion = DublicateProductVersion(previousVersion);

                //Adding the change
                newVersion.Units.Add(unitToAdd);

                this.ProductVersions.Add(newVersion);
                repository.UpdateProductVersionList(this);
            }
            else
            {
                throw new ProductAlreadyHaveUnitException();
            }
        }
Пример #4
0
        public void ActivateProduct()
        {
            ProductVersion newVersion, previousVersion;

            previousVersion = ProductVersions.Last();

            if (previousVersion.IsActive == false)
            {
                //Copying data from previous to new
                newVersion = DublicateProductVersion(previousVersion);

                //Adding the change
                newVersion.IsActive = true;

                this.ProductVersions.Add(newVersion);
                repository.UpdateProductVersionList(this);
            }
            else
            {
                throw new ProductAlreadyActivatedException();
            }
        }
Пример #5
0
        public void ChangeProductSupplier(string supplier)
        {
            ProductVersion newVersion, previousVersion;

            previousVersion = ProductVersions.Last();

            //Copying data from previous to new
            if (previousVersion.Supplier != supplier)
            {
                //Copying data from previous to new
                newVersion = DublicateProductVersion(previousVersion);

                //Adding the change
                newVersion.Supplier = supplier;

                this.ProductVersions.Add(newVersion);
                repository.UpdateProductVersionList(this);
            }
            else
            {
                throw new AlreadyExistingSupplierException(supplier);
            }
        }