Exemplo n.º 1
0
        private Dictionary <string, CountrySales> SummarizeSalesByCountry(List <AppSalesData> data)
        {
            Dictionary <string, CountrySales> result = new Dictionary <string, CountrySales>();

            foreach (AppSalesData a in data)
            {
                if (result.ContainsKey(a.CompanyCountry))
                {
                    result[a.CompanyCountry].TotalRevenue += a.Downloads * a.Price;
                }
                else
                {
                    CountrySales c = new CountrySales(a.CompanyCountry, (a.Downloads * a.Price));
                    result.Add(c.Name, c);
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        private void btnSummary_Click(object sender, EventArgs e)
        {
            CountrySales most = data.Values.ToList()[0], min = data.Values.ToList()[0];
            double       total = 0;

            foreach (CountrySales c in data.Values)
            {
                if (most.TotalRevenue <= c.TotalRevenue)
                {
                    most = c;
                }
                if (min.TotalRevenue >= c.TotalRevenue)
                {
                    min = c;
                }
                total += c.TotalRevenue;
            }
            MessageBox.Show("Bigger seller: " + most.Name + " Total " + most.TotalRevenue.ToString("C") + "\n" +
                            "Worst seller: " + min.Name + " Total " + min.TotalRevenue.ToString("C") + "\n" +
                            "Global revenue: " + total.ToString("C"));
        }