/// <summary> /// Removes the product form the department specific product. /// If the product cannot be found under the department specific products an exception will be thrown. /// </summary> public void RemoveDepartmentSpecificProduct(Department department, DepartmentSpecificProduct dSProduct) { if (department.DepartmentSpecificProducts.Contains(dSProduct)) { department.DepartmentSpecificProducts.Remove(dSProduct); } else { throw new DepartmentNotDepartmentSpecificProductException(); } }
/// <summary> /// Adds the product under the department thus making it a department specific product. /// If the product already can be found under the department it will throw an exception. /// </summary> public void AddDepartmentSpecificProduct(Department department, Product product) { var departmentSpecificProduct = new DepartmentSpecificProduct(department, product); if (department.DepartmentSpecificProducts.Contains(departmentSpecificProduct)) { throw new DepartmentAlreadyDepartmentSpecificProductException(); } else { department.DepartmentSpecificProducts.Add(departmentSpecificProduct); } }