public decimal Calculate(Customer customer, Product product) { if (customer == null) throw new ArgumentNullException("customer"); if (product == null) throw new ArgumentNullException("product"); CountryTax customerCountryTax = this.countryTax.FindOne(new CountryTypeOfTaxSpec(customer.Country.Id, TaxType.Customer)); CountryTax businessCountryTax = this.countryTax.FindOne(new CountryTypeOfTaxSpec(settings.BusinessCountry.Id, TaxType.Business)); return (product.Cost * customerCountryTax.Percentage) + (product.Cost * businessCountryTax.Percentage); }
public static CartProduct Create(Cart cart, Product product, int quantity, ITaxService taxService) { if(cart == null) throw new ArgumentNullException("cart"); if (product == null) throw new ArgumentNullException("product"); return new CartProduct() { Cart = cart, Product = product, Quantity = quantity, Active = true, Created = DateTime.Now, Tax = taxService.Calculate(cart.Customer, product) }; }
private void validateProduct(Guid productId, Product product) { if (product == null) throw new Exception(String.Format("Product was not found with this Id: {0}", productId)); }