Created
July 9, 2015 20:34
-
-
Save angelovstanton/4b5fdff10fe549cf87f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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