Пример #1
0
        public async Task <IActionResult> ControlPanel(SelectQueryDetailsViewModel model)
        {
            var countries = new List <string>();

            countries       = Context_.Countries.Select(x => x.Value).ToList();
            model.Countries = GetSelectListItems(countries);

            if (!string.IsNullOrEmpty(model.Country))
            {
                var parameters = new List <string>();
                model.Parameters = GetSelectListItems(parameters);
                var cities = new List <string>();
                var code   = Context_.GetCodeByCountryName(model.Country);
                cities = await GetCitiesByCountry(code);

                model.Cities = GetSelectListItems(cities);

                if (!string.IsNullOrEmpty(model.City))
                {
                    model.Parameters = GetSelectListItems(parameters);
                }
            }

            var details = Context_.PrepareQuery(model.Country, model.City, model.Parameter);

            model.QueryResults = await ShowResults(details);

            return(View(model));
            //return Redirect("/Home/ControlPanel");
        }
Пример #2
0
        public async Task <IActionResult> ControlPanel()
        {
            var model = new SelectQueryDetailsViewModel();

            model.Title = Context_.GetTitle();

            var countries = new List <string>();

            var cities = new List <string>();

            //Load all countries

            var result = await Context_.GetAllCountriesAsync();

            countries = Context_.Countries.Select(x => x.Value).ToList();

            model.Countries = GetSelectListItems(countries);

            ViewData["Countries"] = model.Countries;

            //Get cities, intially will be empty as no country selected.

            model.Cities = GetSelectListItems(cities);

            ViewData["Cities"] = model.Cities;

            //Select Parameters

            var parameters = await SelectParameters();

            model.Parameters = GetSelectListItems(parameters);

            //Initialize query results from view model

            var queryresult = new List <QueryResult>();

            model.QueryResults = queryresult.ToList();

            return(View(model));
        }