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 async Task <List <CountryTax> > GetTaxes(string countryId) { List <CountryTax> taxes = new List <CountryTax>(); using (var conn = new SqlConnection(ConnectionString)) { await conn.OpenAsync(); using (var cmd = conn.CreateCommand()) { cmd.CommandText = @"SELECT TaxId ,Country ,Percentual FROM dbo.CountryTaxes where country = @Country "; cmd.Parameters.AddWithValue("@Country", countryId); var reader = await cmd.ExecuteReaderAsync(); while (reader.Read()) { CountryTax countryTax = new CountryTax(); countryTax.Country = countryId; countryTax.TaxId = reader.GetInt32(reader.GetOrdinal("TaxId")); countryTax.Percentual = reader.GetDecimal(reader.GetOrdinal("Percentual")); taxes.Add(countryTax); } } conn.Close(); return(taxes); } }
public CountryTaxCreated(CountryTax countryTax) { CountryTax = countryTax; }