コード例 #1
0
        public IActionResult Country()
        {
            CountiesViewModel model = new CountiesViewModel();

            model.Counties = new List <County>();

            using (var command = _dbContext.Database.GetDbConnection().CreateCommand())
            {
                command.CommandText = "SELECT COUNT(PlanInfo.Kommune_Kommunenr) AS antallKommunerTotalt, Fylke.Fylkesnr, Fylke.Fylkesnavn FROM PlanInfo INNER JOIN Kommune ON PlanInfo.Kommune_Kommunenr = Kommune.Kommunenr INNER JOIN Fylke ON Kommune.Fylke_Fylkesnr = Fylke.Fylkesnr WHERE (Kommune.Aktiv = 1) AND(Fylke.Aktiv = 1) GROUP BY Fylke.Fylkesnr, Fylke.Fylkesnavn";
                _dbContext.Database.OpenConnection();
                using (var result = command.ExecuteReader())
                {
                    while (result.Read())
                    {
                        County county = new County();
                        county.MunicipalityCount = result.GetInt32(0);
                        county.Number            = result.GetString(1);
                        county.Name = result.GetString(2);
                        county.GeosynchIntroducedCount = 0;

                        using (var command2 = _dbContext.Database.GetDbConnection().CreateCommand())
                        {
                            command2.CommandText = "SELECT COUNT(PlanInfo.Kommune_Kommunenr) AS GeosynchIntroducedCount FROM PlanInfo INNER JOIN Kommune ON PlanInfo.Kommune_Kommunenr = Kommune.Kommunenr INNER JOIN Fylke ON Kommune.Fylke_Fylkesnr = Fylke.Fylkesnr WHERE(PlanInfo.GeosynkInnfort IS NOT NULL) AND (Kommune.Aktiv = 1) AND (Fylke.Fylkesnr = '" + county.Number + "')";
                            using (var result2 = command2.ExecuteReader())
                            {
                                if (result2.HasRows)
                                {
                                    result2.Read();
                                    county.GeosynchIntroducedCount = result2.GetInt32(0);
                                }
                            }
                        }

                        model.Counties.Add(county);
                    }
                }
            }

            model.GeosynchIntroducedCount = model.Counties.Sum(c => c.GeosynchIntroducedCount);

            ViewBag.ContextViewModel = _contextViewModelHelper.Create();

            return(View("Views/NAP/Management/Aspects/Geosynchronization/Country.cshtml", model));
        }
コード例 #2
0
        public IActionResult Country()
        {
            string       url          = $"{_applicationSettings.UrlThematicGeoJson}/{_geoJsonService.GetFileName()}";
            MapViewModel mapViewModel = new MapViewModel();

            mapViewModel.AddService(_serviceType, url, _layer);

            CountiesViewModel model = new CountiesViewModel()
            {
                Counties     = _countyService.Get(),
                MapViewModel = mapViewModel
            };

            model.DirectUpdateCount = model.Counties.Sum(c => c.DirectUpdateCount);

            ViewBag.ContextViewModel = _contextViewModelHelper.Create();

            return(View("Views/FkbData/Management/Aspects/DirectUpdateInfo/Country.cshtml", model));
        }