public ToppingReport GetPopularToppingReport() { ToppingReport toppingReport = null; try { PizzaServiceClient pizzaServiceClient = new PizzaServiceClient(); List <Pizza> pizzaList = pizzaServiceClient.GetPizzaList(); if (pizzaList != null) { if (pizzaList.Count > 0) { toppingReport = new ToppingReport(); List <string> pizzaToppingList = new List <string>(); List <string> pizzaToppingCombinationList = new List <string>(); foreach (Pizza pizza in pizzaList) { if (pizza.Toppings != null) { if (pizza.Toppings.Count > 0) { //only add combinations to this list if (pizza.Toppings.Count > 1) { pizzaToppingCombinationList.Add(String.Join(",", pizza.Toppings.OrderBy(s => s).ToArray())); } pizzaToppingList.AddRange(pizza.Toppings); } } } if (pizzaToppingList.Count > 0) { toppingReport.popularToppingList = pizzaToppingList.GroupBy(s => s).Select((t, index) => new PopularTopping { Name = t.Key, Count = t.Count() }).OrderByDescending(pt => pt.Count).ToList(); toppingReport.popularToppingList = toppingReport.popularToppingList.Select((t, index) => new PopularTopping { Rank = index + 1, Name = t.Name, Count = t.Count }).OrderBy(pt => pt.Rank).ToList(); } if (pizzaToppingList.Count > 0) { toppingReport.popularToppingCombinationList = pizzaToppingCombinationList.GroupBy(s => s).Select((t, index) => new PopularTopping { Rank = index, Name = t.Key, Count = t.Count() }).OrderByDescending(pt => pt.Count).ToList(); toppingReport.popularToppingCombinationList = toppingReport.popularToppingCombinationList.Select((t, index) => new PopularTopping { Rank = index + 1, Name = t.Name, Count = t.Count }).OrderBy(pt => pt.Rank).ToList(); } } } } catch (Exception exc) { throw exc; } return(toppingReport); }
static void Main(string[] args) { PizzaServiceClient proxy = new PizzaServiceClient("BasicHttpBinding_IPizzaService"); var products = proxy.GetProducts(); var customers = proxy.GetCustomers(); proxy.Close(); }
public List<string> GetProductNames() { var productList = new List<string>(); PizzaServiceClient proxy = new PizzaServiceClient(); productList = proxy.GetProductNames(); return productList; }
public bool CreatePizza(string name) { var svc = new PizzaServiceClient(); var count = Pies.Count; Pies.AddRange(svc.OrderPizza(name, 1).ToList()); return(Pies.Count > count); }
public void ServiceReference() { var svc = new PizzaServiceClient(); Pies = svc.OrderPizza("Pineapple", 1).ToList(); }
//public void ProjectReference() //{ // var p = PizzaMaker.MakePizza("hawaiian"); //} public void ServiceReference() { var svc = new PizzaServiceClient(); Pies = svc.OrderPizza("hawaiian", 0).ToList(); }