Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save angelovstanton/4b5fdff10fe549cf87f5 to your computer and use it in GitHub Desktop.
Save angelovstanton/4b5fdff10fe549cf87f5 to your computer and use it in GitHub Desktop.
public class SalesTaxOrderPurchaseStrategy : IOrderPurchaseStrategy
{
public SalesTaxOrderPurchaseStrategy()
{
this.SalesTaxCalculationService = new SalesTaxCalculationService();
}
public SalesTaxCalculationService SalesTaxCalculationService { get; set; }
public void ValidateOrderSummary(string itemsPrice, ClientPurchaseInfo clientPurchaseInfo)
{
States currentState = (States)Enum.Parse(typeof(States), clientPurchaseInfo.ShippingInfo.State);
decimal currentItemPrice = decimal.Parse(itemsPrice);
decimal salesTax = this.SalesTaxCalculationService.Calculate(currentItemPrice, currentState, clientPurchaseInfo.ShippingInfo.Zip);
PlaceOrderPage.Instance.Validate().EstimatedTaxPrice(salesTax.ToString());
}
public void ValidateClientPurchaseInfo(ClientPurchaseInfo clientPurchaseInfo)
{
if (!clientPurchaseInfo.ShippingInfo.Country.Equals("United States"))
{
throw new ArgumentException("If the NoTaxesOrderPurchaseStrategy is used, the country should be set to United States because otherwise no sales tax is going to be applied.");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment