Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ConfirmedCases,Deaths,Recovered,CountryId")] InfectionData infectionData)
        {
            if (id != infectionData.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(infectionData);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InfectionDataExists(infectionData.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryId"] = new SelectList(_context.Countries, "Id", "Name", infectionData.CountryId);
            return(View(infectionData));
        }
Exemplo n.º 2
0
        async Task <DayAreaDataSet <InfectionData> > LoadInfectionData(DateTime lastUpdate)
        {
            var cacheFile = _env.WebRootPath + "\\data\\infection_data.json";
            var file      = new System.IO.FileInfo(cacheFile);

            if (file.Exists && file.LastWriteTime >= lastUpdate)
            {
                return(JsonConvert.DeserializeObject <DayAreaDataSet <InfectionData> >(await System.IO.File.ReadAllTextAsync(cacheFile)));
            }

            var sources = new IDataSource <DayAreaItem <InfectionData> >[]
            {
                new ItalyInfectionDistrictSource(),
                new ItalyInfectionRegionSource(),
                new ItalyInfectionSource()
            };

            var items = await Task.WhenAll(sources.Select(a => a.LoadAsync()));

            var data = items.SelectMany(a => a);

            var result = new DayAreaDataSet <InfectionData>()
            {
                Days = new List <DayAreaGroupItem <InfectionData> >()
            };

            var tomorrow = DateTime.Today.AddDays(1);

            foreach (var day in data.GroupBy(a => a.Date.Date).Where(a => a.Key < tomorrow))
            {
                var item = new DayAreaGroupItem <InfectionData>()
                {
                    Date   = day.Key,
                    Values = new Dictionary <string, InfectionData>()
                };

                foreach (var area in day.GroupBy(a => a.AreaId))
                {
                    if (area.Key == "R4")
                    {
                        item.Values[area.Key] = InfectionData.Combine(area.Select(a => a.Value));
                    }
                    else
                    {
                        var value = area.OrderByDescending(a => a.Date).First();
                        item.Values[area.Key] = value.Value;
                    }
                }

                result.Days.Add(item);
            }
            ;

            await System.IO.File.WriteAllTextAsync(cacheFile, JsonConvert.SerializeObject(result, new JsonSerializerSettings()
            {
                NullValueHandling = NullValueHandling.Ignore
            }));

            return(result);
        }
Exemplo n.º 3
0
 private void Start()
 {
     coord   = FindObjects.GameLogic.GetComponent <ConvertCoordinates>();
     message = FindObjects.GameLogic.GetComponent <UIMessage>();
     text    = FindObjects.GameLogic.GetComponent <GameText>();
     color   = FindObjects.GameLogic.GetComponent <GameColor>();
     data    = FindObjects.GameLogic.GetComponent <InfectionData>();
 }
Exemplo n.º 4
0
        private void Start()
        {
            board         = GetComponent <DungeonBoard>();
            coord         = GetComponent <ConvertCoordinates>();
            actorData     = GetComponent <ActorData>();
            potionData    = GetComponent <PotionData>();
            infectionData = GetComponent <InfectionData>();

            getUI = FindObjects.GetUIText;
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,ConfirmedCases,Deaths,Recovered,CountryId")] InfectionData infectionData)
        {
            if (ModelState.IsValid)
            {
                _context.Add(infectionData);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryId"] = new SelectList(_context.Countries, "Id", "Name", infectionData.CountryId);
            return(View(infectionData));
        }
Exemplo n.º 6
0
        private void Start()
        {
            random        = FindObjects.GameLogic.GetComponent <RandomNumber>();
            infectionData = FindObjects.GameLogic.GetComponent <InfectionData>();

            if (GetComponent <MetaInfo>().IsPC)
            {
                iRate     = GetComponent <PCInfection>() as IInfectionRate;
                iRecovery = GetComponent <PCInfection>() as IInfectionRecovery;
            }
            else
            {
                iRate     = GetComponent <NPCInfection>() as IInfectionRate;
                iRecovery = GetComponent <NPCInfection>() as IInfectionRecovery;
            }
        }
Exemplo n.º 7
0
 private void Start()
 {
     infectionData = FindObjects.GameLogic.GetComponent <InfectionData>();
     dungeon       = FindObjects.GameLogic.GetComponent <DungeonBoard>();
     coords        = FindObjects.GameLogic.GetComponent <ConvertCoordinates>();
 }
Exemplo n.º 8
0
 private void Start()
 {
     actorData     = FindObjects.GameLogic.GetComponent <ActorData>();
     infectionData = FindObjects.GameLogic.GetComponent <InfectionData>();
 }