public ViewResult Chart()
        {
            httpclient.BaseAddress = new Uri(api_link);

            HttpResponseMessage response = httpclient.GetAsync(api_link).GetAwaiter().GetResult();
            DbDomain            d        = new DbDomain(_context);

            if (d._context.Covid_Conditions_data.ToList().Count == 0)
            {
                d.covidConditionPost(covid_conditions);
            }

            var results = from p in _context.Covid_Conditions_data
                          group p by p.condition_group into g
                          select new { condition_group = g.Key, covid_19_deaths = g.Sum(c => Convert.ToInt64(c.covid_19_deaths)) };

            List <string> ChartLabels = new List <string>();

            ChartLabels = results.Select(p => p.condition_group).ToList();
            List <long> ChartData = new List <long>();

            ChartData = results.Select(p => p.covid_19_deaths).ToList();

            ChartModel Model = new ChartModel
            {
                ChartType = "bar",
                Labels    = String.Join(",", ChartLabels.Select(d => "'" + d + "'")),
                Data      = String.Join(",", ChartData.Select(d => d)),
                Title     = "Covid deaths by Condition Group"
            };

            return(View(Model));
        }
        public IActionResult Data()
        {
            httpclient.BaseAddress = new Uri(api_link);

            HttpResponseMessage response = httpclient.GetAsync(api_link).GetAwaiter().GetResult();

            string covidData = null;

            //var responseTask = httpclient.GetAsync(api_link);
            //responseTask.Wait();
            //var result = responseTask.Result;
            if (response.IsSuccessStatusCode)
            {
                //Get the data from api and store it as string in covidData variable
                covidData = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
            }
            if (!covidData.Equals(""))
            {
                // JsonConvert is part of the NewtonSoft.Json Nuget package which convert string to json
                covid_conditions.data = JsonConvert.DeserializeObject <List <Covid_Condition> >(covidData);
            }

            DbDomain d = new DbDomain(_context);

            //add the data to db
            if (d._context.Covid_Conditions_data.ToList().Count == 0)
            {
                //post the data into database
                d.covidConditionPost(covid_conditions);
            }


            return(View(d._context.Covid_Conditions_data.ToList()));
        }
        public IActionResult Update(string cond)
        {
            DbDomain d = new DbDomain(_context);
            //fetch the records which match the given condition
            var _cov = d._context.Covid_Conditions_data.Where(c => c.condition == cond).First();

            return(View(_cov));
        }