// GET: api/Covid
        public async Task <CovidModel> GetAsync()
        {
            SummaryViewModel summary = new SummaryViewModel();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(baseUrl);

                HttpResponseMessage responseMessage = await client.GetAsync("summary");

                if (responseMessage.IsSuccessStatusCode)
                {
                    //Storing the response details recieved from web api
                    var covidResponse = responseMessage.Content
                                        .ReadAsStringAsync().Result;

                    summary = JsonConvert.DeserializeObject <SummaryViewModel>(covidResponse);
                }
            }

            CovidModel covid = new CovidModel
            {
                Global    = summary.Global,
                Countries = summary.Countries.OrderByDescending(c => c.TotalConfirmed)
            };

            return(covid);
        }
Пример #2
0
        protected override async Task OnInitializedAsync()
        {
            CurrentCovidData = await CovidDataService.GetCovidData();

            FilteredCovidData = new CovidModel
            {
                Cities = new List <City>(CurrentCovidData.Cities)
            };
        }
Пример #3
0
    void Start()
    {
        Infected = (UnityEngine.Random.Range(0f, 1f) > 0.9f);

        var distanceWeight = UnityEngine.Random.Range(0.001f, 0.1f);
        var healthWeight   = UnityEngine.Random.Range(0.001f, 0.3f);
        var maskWeight     = UnityEngine.Random.Range(0.001f, 0.4f);

        CovidInfection = new CovidModel(this.gameObject, distanceWeight, healthWeight, maskWeight, this.transform.GetComponent <Mask>().Radius, Infected);
    }
        public CovidModel GetCovidData(string id)
        {
            var covidOutput = new CovidModel();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Constants.COVIDURL);
                if (string.IsNullOrEmpty(id))
                {
                    var response = client.GetStringAsync(Constants.ENDPOINTWORLD).Result;
                    covidOutput.worldModel = JsonSerializer.Deserialize <WorldModel>(response);
                }
                else
                {
                    var response = client.GetStringAsync(Constants.ENDPOINTWORLD + "/" + id).Result;
                    covidOutput.countryModel = JsonSerializer.Deserialize <CountryModel>(response);
                }
            }
            return(covidOutput);
        }