Esempio n. 1
0
        public async Task GetStandings(string chapter, int year, int yearFraction)
        {
            Standings.Clear();

            if (!ChapterList.ContainsKey(chapter))
            {
                return;
            }

            ValueColumnCaption = UnitOfMeasureList[chapter];

            var data = await CountyStandingsProvider.GetData(ChapterList[chapter], year, yearFraction);

            foreach (var item in data)
            {
                Standings.Add(item);
            }

            HasData         = data.Count > 0;
            DoesNotHaveData = !HasData;

            if (DoesNotHaveData)
            {
                var lastData = (await CountyDetailsProvider.GetData(1, ChapterList[chapter]))
                               .OrderByDescending(x => x.Year)
                               .ThenByDescending(x => x.YearFraction)
                               .FirstOrDefault();
                LastAvailableYear         = lastData.Year;
                LastAvailableYearFraction = lastData.YearFraction;
            }
        }
Esempio n. 2
0
        public async Task <object> GetStandings(string chapter, int year, int yearFraction)
        {
            if (!ChapterList.ContainsKey(chapter))
            {
                return(null);
            }

            var valueColumnCaption = UnitOfMeasureList[chapter];

            var data = await CountyStandingsProvider.GetData(ChapterList[chapter], year, yearFraction);

            return(new StandingsDto {
                ValueColumnCaption = valueColumnCaption, Data = data
            });
        }
Esempio n. 3
0
        public async Task GetStandings(string chapter, int year, int yearFraction)
        {
            ValueColumnCaption = "Lei";

            Standings.Clear();

            if (!ChapterList.ContainsKey(chapter))
            {
                return;
            }

            var data = await CountyStandingsProvider.GetData(ChapterList[chapter], year, yearFraction);

            foreach (var item in data)
            {
                Standings.Add(item);
            }
        }
        public async Task GetChapterData(int countyId, int countyId2, string chapter)
        {
            if (!ChapterList.ContainsKey(chapter) || countyId < 1)
            {
                return;
            }

            ValueColumnCaption = string.Format("{0} {1}", UnitOfMeasureList[chapter], CountyAbbreviations[CountyList.First(x => x.Value == countyId).Key]);

            var data = await CountyDetailsProvider.GetData(countyId, ChapterList[chapter]);

            HasData = data.Count > 0;

            if (countyId2 >= 1 && countyId != countyId2)
            {
                var data2 = await CountyDetailsProvider.GetData(countyId2, ChapterList[chapter]);

                foreach (var item2 in data2)
                {
                    var item = data.FirstOrDefault(x => x.Year == item2.Year && x.YearFraction == item2.YearFraction);
                    if (item != null)
                    {
                        item.Value2 = item2.Value;
                    }
                }

                Value2ColumnCaption = string.Format("{0} {1}", UnitOfMeasureList[chapter], CountyAbbreviations[CountyList.First(x => x.Value == countyId2).Key]);

                Value2ColumnVisibility = true;
            }
            else
            {
                Value2ColumnVisibility = false;
            }

            ChapterData.Clear();
            ChapterDataReversed.Clear();

            foreach (var item in data)
            {
                ChapterData.Add(item);
                ChapterDataReversed.Insert(0, item);
            }
        }
        public async Task GetStandings(string chapter, int year, int yearFraction)
        {
            if (!ChapterList.ContainsKey(chapter))
            {
                return;
            }

            ValueColumnCaption = UnitOfMeasureList[chapter];

            var data = await CountyStandingsProvider.GetData(ChapterList[chapter], year, yearFraction);

            //var y2015 = await CountyStandingsProvider.GetData(ChapterList[chapter], 2015, -1);
            //var y2016 = await CountyStandingsProvider.GetData(ChapterList[chapter], 2016, -1);

            //Debug.WriteLine($"Indicator: {ChapterList[chapter]}");
            //foreach(var item in y2015.OrderBy(x => x.County))
            //{
            //    var county = item.County;
            //    var value2016 = y2016.Find(x => x.County == county).Value;
            //    Debug.WriteLine($"{county}, 2015: {item.Value}, 2016: {value2016}, diferenta: {value2016 - item.Value} ({Math.Round((value2016 - item.Value) * 100.0 / item.Value, 2)}%)");
            //}

            Standings.Clear();

            foreach (var item in data)
            {
                Standings.Add(item);
            }

            HasData         = data.Count > 0;
            DoesNotHaveData = !HasData;

            if (DoesNotHaveData)
            {
                var lastData = (await CountyDetailsProvider.GetData(1, ChapterList[chapter]))
                               .OrderByDescending(x => x.Year)
                               .ThenByDescending(x => x.YearFraction)
                               .FirstOrDefault();
                LastAvailableYear         = lastData.Year;
                LastAvailableYearFraction = lastData.YearFraction;
            }
        }
Esempio n. 6
0
        public async Task GetChapterData(int countyId, string chapter)
        {
            ValueColumnCaption = "Lei";

            ChapterData.Clear();
            ChapterDataReversed.Clear();

            if (!ChapterList.ContainsKey(chapter) || countyId < 1)
            {
                return;
            }

            var data = await CountyDetailsProvider.GetData(countyId, ChapterList[chapter]);

            foreach (var item in data)
            {
                ChapterData.Add(item);
                ChapterDataReversed.Insert(0, item);
            }
        }
        public async Task <object> GetCountyDetails(int countyId, int countyId2, string chapter, bool needToProcessAllYear)
        {
            if (!ChapterList.ContainsKey(chapter) || countyId < 1)
            {
                return(null);
            }

            var countyAbbreviations = new Dictionary <string, string>()
            {
                { "Alba", "AB" },
                { "Arad", "AR" },
                { "Arges", "AG" },
                { "Bacau", "BC" },
                { "Bihor", "BH" },
                { "Bistrita-Nasaud", "BN" },
                { "Botosani", "BT" },
                { "Brasov", "BV" },
                { "Braila", "BR" },
                { "Buzau", "BZ" },
                { "Caras-Severin", "CS" },
                { "Calarasi", "CL" },
                { "Cluj", "CJ" },
                { "Constanta", "CT" },
                { "Covasna", "CV" },
                { "Dambovita", "DB" },
                { "Dolj", "DJ" },
                { "Galati", "GL" },
                { "Giurgiu", "GR" },
                { "Gorj", "GJ" },
                { "Harghita", "HR" },
                { "Hunedoara", "HD" },
                { "Ialomita", "IL" },
                { "Iasi", "IS" },
                { "Ilfov", "IF" },
                { "Maramures", "MM" },
                { "Mehedinti", "MH" },
                { "Mures", "MS" },
                { "Neamt", "NT" },
                { "Olt", "OT" },
                { "Prahova", "PH" },
                { "Satu Mare", "SM" },
                { "Salaj", "SJ" },
                { "Sibiu", "SB" },
                { "Suceava", "SV" },
                { "Teleorman", "TR" },
                { "Timis", "TM" },
                { "Tulcea", "TL" },
                { "Vaslui", "VS" },
                { "Valcea", "VL" },
                { "Vrancea", "VN" },
                { "Bucuresti", "B" },
            };

            var countyList = CountiesSeeder.GetData().ToDictionary(x => x.Name, x => x.Id);

            var valueColumnCaption = string.Format("{0} {1}", UnitOfMeasureList[chapter], countyAbbreviations[countyList.First(x => x.Value == countyId).Key]);

            var data = (await CountyDetailsProvider.GetData(countyId, ChapterList[chapter], needToProcessAllYear))
                       .OrderByDescending(x => x.Year)
                       .ThenByDescending(x => x.YearFraction)
                       .Select(x => new DataDto
            {
                Id           = x.Id,
                CountyId     = x.CountyId,
                Subchapter   = x.Subchapter,
                Year         = x.Year,
                YearFraction = x.YearFraction,
                Value        = x.Value,
                Value2       = x.Value2
            })
                       .ToList();

            string value2ColumnCaption = null;
            bool   value2ColumnVisibility;  // kept for compatibility with the mobile VM in case I ever want to merge the duplicated logic

            if (countyId2 >= 1 && countyId != countyId2)
            {
                var data2 = await CountyDetailsProvider.GetData(countyId2, ChapterList[chapter], needToProcessAllYear);

                foreach (var item2 in data2)
                {
                    var item = data.FirstOrDefault(x => x.Year == item2.Year && x.YearFraction == item2.YearFraction);
                    if (item != null)
                    {
                        item.Value2 = item2.Value;
                    }
                }

                value2ColumnCaption = string.Format("{0} {1}", UnitOfMeasureList[chapter], countyAbbreviations[countyList.First(x => x.Value == countyId2).Key]);

                value2ColumnVisibility = true;
            }
            else
            {
                value2ColumnVisibility = false;
            }

            return(new CountyDetailsDto {
                ValueColumnCaption = valueColumnCaption, Value2ColumnCaption = value2ColumnCaption, Data = data
            });
        }