Пример #1
0
        public void Filter()
        {
            var electionsRepo = new ElectionsRepository();

            var countries = electionsRepo.GetCountryNames();

            foreach (var electionCountry in countries)
            {
                var countryElections = electionsRepo.GetByCountry(electionCountry).ToList();

                countryElections.RemoveAll(entity => entity.Year < Year);

                //remove the file if there is no data above the YEAR
                if (countryElections.Count <= 0)
                {
                    File.Delete(_processedPath + "Election_" + countryElections[0].CountryCode +
                                ".json");
                    continue;
                }

                using (var file =
                           File.CreateText(_processedPath + "Election_" + countryElections[0].CountryCode +
                                           ".json"))
                {
                    var serializer = new JsonSerializer();
                    serializer.Serialize(file, countryElections);
                }
            }
        }
Пример #2
0
 public HomeController(ElectionsRepository election)
 {
     _election = election;
 }