public void Update(ProductState productState, ProductStateData productStateData)
 {
     if (productState != null)
     {
         if (productStateData != null)
         {
             if (productStateData.IsAmountChanged == true)
             {
                 productState.Amount = productStateData.Amount;
                 context.ReportData.LastChangeTime = DateTime.Now;
             }
             if (productStateData.IsPriceNettoChanged == true)
             {
                 productState.PriceNetto           = productStateData.PriceNetto;
                 context.ReportData.LastChangeTime = DateTime.Now;
             }
             if (productStateData.IsTaxRateChanged == true)
             {
                 productState.TaxRate = productStateData.TaxRate;
                 context.ReportData.LastChangeTime = DateTime.Now;
             }
         }
         else
         {
             throw new ArgumentNullException("ProductStateData can not be null");
         }
     }
     else
     {
         throw new ArgumentNullException("ProductState can not be null");
     }
 }
 public void Add(ProductState productState)
 {
     if (productState != null)
     {
         if (productState.Product != null)
         {
             if (context.ProductStates.FirstOrDefault(p => p.Product.Id == productState.Product.Id) == null) // if no ProductState describing the same product
             {
                 context.ProductStates.Add(productState);
                 context.ReportData.LastChangeTime = DateTime.Now;
             }
             else
             {
                 throw new DuplicateException("Cannot add productState describing the same product.");
             }
         }
         else
         {
             throw new ArgumentNullException("Can not add ProductState without Product");
         }
     }
     else
     {
         throw new ArgumentNullException("Product can not be null");
     }
 }
 public void Delete(ProductState productState)
 {
     if (productState.Product != null)
     {
         if (context.ProductStates.Contains(productState))
         {
             context.ProductStates.Remove(productState);
             context.ReportData.LastChangeTime = DateTime.Now;
         }
         else
         {
             throw new NotFoundException("Product State not found");
         }
     }
     else
     {
         throw new DeleteReferencesException("Can not delete ProductData because of the reference to some Product");
     }
 }