namespace StrategyPattern.Models { public class Event { public int ID { get; set; } public Price TicketPrice { get; set; } public string Name { get; set; } public Location Location { get; set; } public DateTime Date { get; set; } } public class Location { public string Name { get; set; } public string Address1 { get; set; } public string Address2 { get; set; } public string State { get; set; } public string Zipcode { get; set; } } } //and in another class: namespace StrategyPattern.Models { public class Price { IDiscountStrategy _discountStrategy; public decimal Cost { get; set; } public decimal DiscountedCost { get; set; } /// /// When you instantiate a price class, it defaults to doing nothing (returning the same cost). /// public Price() { _discountStrategy = new NullDiscountStrategy(); } /// /// Swaps out and recalculates the cost of a given Price through the applied discount algorithm /// ///public void SetAndApplyDiscountStrategy(IDiscountStrategy discountStrategy) { _discountStrategy = discountStrategy; this.DiscountedCost = _discountStrategy.ApplyDiscount(this.Cost); } } } //and finally our repository: namespace StrategyPattern.Repositories { public class FakeEventRepository : IEventRepository { public IEnumerable GetEvents(StrategyPattern.Enumerations.EventEnumerations.CustomerType customerType) { //Hydrate list with mock data. Each event has a base price (used for the standard customer type) IEnumerable events = new List() { {new Event{ Name = "Symposium on Software Development", Date = new DateTime(2015, 12, 15), TicketPrice = new Price{ Cost = 150}, Location = new Location{ Address1 = "55 test street", Address2="", Name="The Blue Theater", State="NY", Zipcode="11757" }}}, {new Event{ Name = "SQL Injection and XSS Attacks", Date = new DateTime(2016, 1, 21), TicketPrice = new Price{ Cost = 75} , Location = new Location{ Address1 = "55 test street", Address2="", Name="The Blue Theater", State="NY", Zipcode="11757" }}}, {new Event{ Name = "Security in Software Development", Date = new DateTime(2015, 11, 14), TicketPrice = new Price{ Cost = 250}, Location = new Location{ Address1 = "55 test street", Address2="", Name="The Blue Theater", State="NY", Zipcode="11757" }}} }; //Determine which strategy to apply based on the customer type IDiscountStrategy discountStrategy = DiscountFactory.GetDiscountStrategyForCustomerType(customerType); //Apply the discount selected to each product, and return the discounted collection return events.ApplyDiscount(discountStrategy); } } }