Ejemplo n.º 1
0
        public async Task GetChild(T entity, Expression <Func <T, object> > propertyExpression)
        {
            // Note: I know that I use this method only to load counties; if this changes in the future, then I need to change the implementation
            var dataEntity = entity as Data;

            dataEntity.County = CountiesSeeder.GetData().First(x => x.Id == dataEntity.CountyId);
        }
        public List <CountyDto> GetCounties()
        {
            var counties = CountiesSeeder.GetData().Select(x => new CountyDto {
                Id = x.Id, Name = x.Name
            }).ToList();

            return(counties);
        }
Ejemplo n.º 3
0
        private void SeedDatabase()
        {
            var counties = CountiesSeeder.GetData();

            _db.InsertOrReplaceAll(counties);

            var averageGrossSalaries = AverageGrossSalarySeeder.GetData();

            _db.DeleteAll <AverageGrossSalary>();
            _db.InsertAll(averageGrossSalaries);

            var averageNetSalaries = AverageNetSalarySeeder.GetData();

            _db.DeleteAll <AverageNetSalary>();
            _db.InsertAll(averageNetSalaries);

            var numberOfTourists = NumberOfTouristsSeeder.GetData();

            _db.DeleteAll <NumberOfTourists>();
            _db.InsertAll(numberOfTourists);

            var numberOfNights = NumberOfNightsSeeder.GetData();

            _db.DeleteAll <NumberOfNights>();
            _db.InsertAll(numberOfNights);

            var numberOfEmployees = NumberOfEmployeesSeeder.GetData();

            _db.DeleteAll <NumberOfEmployees>();
            _db.InsertAll(numberOfEmployees);

            var numberOfUnemployed = UnemployedSeeder.GetData();

            _db.DeleteAll <Unemployed>();
            _db.InsertAll(numberOfUnemployed);

            var export = ExportFobSeeder.GetData();

            _db.DeleteAll <ExportFob>();
            _db.InsertAll(export);

            var import = ImportCifSeeder.GetData();

            _db.DeleteAll <ImportCif>();
            _db.InsertAll(import);

            var sold = SoldFobCifSeeder.GetData();

            _db.DeleteAll <SoldFobCif>();
            _db.InsertAll(sold);
        }
Ejemplo n.º 4
0
        private async Task <string> GetDescriptionForCountyDetails()
        {
            var query = this.HttpContext.Request.Query;

            var dataProviderController = _serviceProvider.GetService(typeof(CountyDetailsController)) as CountyDetailsController;

            Func <int, int, string, bool, Task <object> > getData = (countyId1Param, countyId2Param, chapterParam, needToProcessAllYearParam) => dataProviderController.GetCountyDetails(countyId1Param, countyId2Param, chapterParam, needToProcessAllYearParam);

            var needToProcessAllYear = bool.Parse(query["needToProcessAllYear"]);
            var countyId1            = int.Parse(query["countyId1"]);
            var countyId2            = int.Parse(query["countyId2"]);
            var data = await getData(countyId1, countyId2, query["chapter"], needToProcessAllYear) as CountyDetailsDto;

            var pointOfInterests = data.Data.OrderByDescending(x => x.Year)
                                   .ThenByDescending(x => x.YearFraction)
                                   .First();

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

            var description = $"In anul {pointOfInterests.Year}{(needToProcessAllYear ? string.Empty : $", luna {pointOfInterests.YearFraction}")}, pentru judetul {countyList.First(x => x.Value == countyId1).Key}, indicatorul statistic '{query["chapter"]}' a avut valoarea {pointOfInterests.Value}.";
        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
            });
        }