Ejemplo n.º 1
0
        public CongressCandidateSectionViewModel(Entities.Country country)
        {
            Info           = new CongressInfoViewModel(country);
            CountryRegions = CreateSelectList(country.Regions.ToList(), true, "Select Region");
            CountryRegions.Add(new SelectListItem()
            {
                Text = "All regions", Value = "ALL"
            });
            CountryParties = CreateSelectList(country.Parties.ToList(), p => p.Entity.Name, p => p.ID, true, "Select Party");

            var lastVoting = country.GetLastCongressCandidateVoting();

            if (SessionHelper.CurrentEntity.Is(EntityTypeEnum.Citizen))
            {
                CanVote = !lastVoting.HasVoted(SessionHelper.LoggedCitizen) &&
                          lastVoting.VotingStatusID == (int)VotingStatusEnum.Ongoing;
            }

            VotingStatus = (VotingStatusEnum)lastVoting.VotingStatusID;
            CountryID    = country.ID;
            VotingDay    = lastVoting.VotingDay;
            DaysLeft     = lastVoting.VotingDay - GameHelper.CurrentDay;
        }
Ejemplo n.º 2
0
        public static void convertCsvToDictionary(List <dynamic> LocationList, string type)
        {
            foreach (var lcsv in LocationList)
            {
                var    dict     = (IDictionary <string, object>)lcsv;
                string Country  = lcsv.countryregion.ToLower();
                string Province = lcsv.provincestate.ToLower();


                if (!String.IsNullOrEmpty(Country))
                {
                    CountryRegions.Add(Country.ToLower());
                }
                if (!String.IsNullOrEmpty(Province))
                {
                    ProvinceStates.Add(Province.ToLower());
                    LocationKey lk = new LocationKey(Country, Province);
                    if (!CountryProvinces.ContainsKey(Country))
                    {
                        CountryProvinces.Add(Country, new Country());
                    }
                    //CountryProvinces.Add(lk, new Location(Country, Province, new Coordinates(lcsv.Lat, lcsv.Long)));
                    else
                    {
                        if (!CountryProvinces[Country].Provinces.Contains(Province))
                        {
                            CountryProvinces[Country].Provinces.Add(Province);
                        }
                    }
                }



                DateTime firstDate     = DateTime.Parse("1/1/2020");
                DateTime endDate       = DateTime.Now;
                int      daysToAttempt = (endDate - firstDate).Days + 10;


                for (int i = 0; i < daysToAttempt; i++)
                {
                    StatusCount statusCount   = new StatusCount();
                    DateTime    dateToAttempt = firstDate.AddDays(i);
                    string      targetDay     = dateToAttempt.ToString("Mdyy");

                    if (dict.TryGetValue(targetDay, out var count) && !String.IsNullOrEmpty(count.ToString()))
                    {
                        int intcount = int.Parse(count.ToString());
                        if (type == "Confirmed")
                        {
                            statusCount.Confirmed = intcount;
                        }
                        else if (type == "Deaths")
                        {
                            statusCount.Deaths = intcount;
                        }
                        else if (type == "Recovered")
                        {
                            statusCount.Recovered = intcount;
                        }

                        Occurences occurences = new Occurences();
                        occurences.DateOccurrences.Add(dateToAttempt, statusCount);

                        LocationKey location = new LocationKey(Country.ToLower(), Province.ToLower());

                        if (!LocationOccurrences.ContainsKey(location))
                        {
                            LocationOccurrences.Add(location, occurences);
                        }


                        if (!LocationOccurrences[location].DateOccurrences.ContainsKey(dateToAttempt))
                        {
                            LocationOccurrences[location].DateOccurrences[dateToAttempt] = new StatusCount();
                        }

                        if (type == "Confirmed")
                        {
                            LocationOccurrences[location].DateOccurrences[dateToAttempt].Confirmed = statusCount.Confirmed;
                        }
                        else if (type == "Deaths")
                        {
                            LocationOccurrences[location].DateOccurrences[dateToAttempt].Deaths = statusCount.Deaths;
                        }
                        else if (type == "Recovered")
                        {
                            LocationOccurrences[location].DateOccurrences[dateToAttempt].Recovered = statusCount.Recovered;
                        }
                    }
                }
            }
        }