Example #1
0
        public IActionResult country(string countryName)
        {
            ViewBag.country = countryName;
            try
            {
                ViewBag.countryExists = "true";
                database db = new database(database.maindb);
                db.AddParam("?country", countryName);
                MySqlDataReader rd = db.ExecuteReader("select * from countries where lower(country)=lower(?country)");
                if (!rd.HasRows)
                {
                    ViewBag.climate = "N.A.";
                    ViewBag.death_rate = "N.A.";
                    ViewBag.obesity = "N.A.";
                }

                while (rd.Read())
                {
                    ViewBag.climate = rd.GetString("climate");
                    double death_rate = rd.GetDouble("death_rate");
                    if (death_rate == 0) ViewBag.death_rate = "N.A.";
                    else ViewBag.death_rate = death_rate;
                    double obesity = rd.GetDouble("obesity");
                    if (obesity == 0) ViewBag.obesity = "N.A.";
                    else ViewBag.obesity = obesity;
                }
                Dictionary<string, Country> cslist = new Countries().getDictionar();
                ViewBag.code = "";
                try
                {
                    ViewBag.code = cslist[countryName].Code;
                }
                catch { }

            }
            catch { }
            ViewBag.nr = 0;
            try
            {
                ObjectResult obj = (ObjectResult)new MeAd.Raml.SearchController().Get(countryName);
                Dictionary<string, Countries.CountryDiseases> countryDiseases = (Dictionary<string, Countries.CountryDiseases>)obj.Value;
                ViewBag.countryDiseases = countryDiseases;
            }
            catch { }
            return View();
        }
Example #2
0
        public IActionResult ViewCountries()
        {
            Dictionary<string, Country> cslist = new Countries().getDictionar();

            string htmlStr = "";

            foreach (string i in cslist.Keys)
            {
                htmlStr += "<a href='../country/" + i + "'>" + i + "</a><br>";
            }
            ViewBag.countries = htmlStr;
            return View();
        }
Example #3
0
        public string getCountriesDiseaseDensity(string id, int min, int max)
        {
            string js = getCountriesDisease(id);

            Dictionary<string, int> diseases = JsonConvert.DeserializeObject<Dictionary<string, int>>(js);

            Dictionary<string, Country> cslist = new Countries().getDictionar();

            foreach (KeyValuePair<string, Country> it in cslist.ToList())
            {
                if ((it.Value.Density <= min || it.Value.Density >= max))
                {
                    if (diseases.ContainsKey(it.Key))
                    {
                        diseases[it.Key]=0;
                    }
                    else
                    {
                        diseases.Add(it.Key,0);
                    }
                }
            }

            return JsonConvert.SerializeObject(diseases);
        }