Exemplo n.º 1
0
 public bool CheckIfProductIsActive()
 {
     if (ProductVersions.Count != 0)
     {
         return(ProductVersions.Last().IsActive);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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);
            }
        }