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