#pragma warning disable DV0001 // Invalid dependency public static bool ValidateOrder(this TailspinController controller, Order order) #pragma warning restore DV0001 // Invalid dependency { bool result = true; //make sure there are more than one item result = order.Items.Count > 0; //we have a credit card if (result) { result = order.CreditCard != null; } //valid number? if (result) { result = order.CreditCard.IsValid(); } //everything adds up if (result) { result = order.SubTotal + order.ShippingAmount + order.TaxAmount == order.Total; } return(result); }
public static Transaction AuthorizeCreditCard(this TailspinController controller, Order order) { //this is a fake processor for testing... //if there are transaction errors, //pop them into the TransactionErrors on the Transaction object //for display to the end user string authCode = System.Guid.NewGuid().ToString().Substring(0, 10); Transaction t = new Transaction(order.ID, order.Total, authCode, "FakePaymentGateway"); return(t); }
public static decimal CalculateTax(this TailspinController controller, ShoppingCart cart) { Dictionary <string, decimal> TaxTable = new Dictionary <string, decimal>(); TaxTable.Add("HI", .0512M); TaxTable.Add("CA", .0815M); TaxTable.Add("WA", .0612M); decimal result = 0; decimal rate = 0; //check the rates against the shipping address if (TaxTable.ContainsKey(cart.ShippingAddress.StateOrProvince)) { rate = TaxTable[cart.ShippingAddress.StateOrProvince]; } result = rate * cart.SubTotal; return(result); }
#pragma warning disable DV0001 // Invalid dependency public static string CreateOrderNumber(this TailspinController controller, Order order) #pragma warning restore DV0001 // Invalid dependency { return("MVC-" + Guid.NewGuid().ToString().Substring(0, 8)); }
public static string CreateOrderNumber(this TailspinController controller, Order order) { return("MVC-" + Guid.NewGuid().ToString().Substring(0, 8)); }