Exemplo n.º 1
0
        private static void CreateDefaultIncidents(IServiceProvider serviceProvider)
        {
            var firemanTeamRepository  = serviceProvider.GetService <IFiremanTeamRepository>();
            var fireIncidentRepository = serviceProvider.GetService <IFireIncidentRepository>();

            var           incidents = fireIncidentRepository.GetAll().Any();
            List <string> teamnames = new List <string>()
            {
                "UtopiaHeros", "Titanium", "FireUtopia", "WaterTeam", "HopeTeam", "PowerTeam"
            };
            List <string> addresses = new List <string>()
            {
                "39455 Paige Estate Apt. 223", "1549 Pfannerstill Union Suite 107", "5889 Rashad Haven Suite 443", "14936 Effie Cape", "84940 Darion Canyon Apt. 245", "1209 Mills Forges Suite 630", "5526 Elwin Cliff", "426 Kohler Pass", "563 Lowe Summit", "8277 Lebsack Alley Apt. 692"
            };
            List <string> reasons = new List <string>()
            {
                "Gas", "Smoking in bedrooms", "Curious children", "Heating", "Electrical equipment", "Faulty wiring", "Barbeques", "Flammable liquids", "Lighting", "Cooking equipment"
            };
            List <int> deads = new List <int>()
            {
                1, 2, 0, 1, 0, 1, 0, 1, 0, 0
            };
            List <int> inj = new List <int>()
            {
                4, 3, 2, 1, 4, 2, 3, 1, 2, 2
            };

            if (!incidents)
            {
                for (int i = 0; i < addresses.Count; i++)
                {
                    var          team     = firemanTeamRepository.GetByName(teamnames[i % 6]);
                    FireIncident incident = new FireIncident()
                    {
                        Address     = addresses[i],
                        Status      = IncidentStatus.Done,
                        Date        = DateTime.Now.AddDays(-(i * 200)),
                        Reason      = reasons[i],
                        Injured     = inj[i],
                        Dead        = deads[i],
                        FiremanTeam = team
                    };
                    fireIncidentRepository.Save(incident);
                }
            }
        }
Exemplo n.º 2
0
 public WeatherData GetWeatherDataFromFireIncident(FireIncident incident)
 {
     try
     {
         using (HttpClient client = new HttpClient())
         {
             string url = string.Format(
                 "http://api.openweathermap.org/data/2.5/weather?lat={0}&lon={1}&appid=f48d93cf79caeb4cdf990386aa8df5f3&units=metric",
                 incident.Position.Latitude,
                 incident.Position.Longitude);
             HttpResponseMessage response = client.GetAsync(url).Result;
             string json = response.Content.ReadAsStringAsync().Result;
             return(new WeatherData());
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }