/// <summary> /// The method combines the population information of countries obtained from /// database and API in Dictionary, if the same country information in both /// data sources information from database is given preference. /// </summary> /// <returns>Dictionary with all the countries and its population /// key as country name and value as populations /// </returns> public Dictionary <string, int> GetCountryPopulations() { Dictionary <string, int> dict = sqliteDbManagerImpl.GetCountryPopulations(); StatsUtilityServices helper = new StatsUtilityServices(); IStatService statServiceFromConcrete = new ConcreteStatService(); List <Tuple <string, int> > listFromConcrete = statServiceFromConcrete.GetCountryPopulations(); helper.AddPopulationsToDictionary(dict, listFromConcrete); Console.WriteLine("Total results and merging both lists --------------------------------------size : " + dict.Count); return(dict); }
static void Main(string[] args) { Console.WriteLine("Started"); Console.WriteLine("Getting DB Connection..."); IDbManager db = new SqliteDbManager(); DbConnection conn = db.getConnection(); if (conn == null) { Console.WriteLine("Failed to get connection"); } StatsUtilityServices helperServices = new StatsUtilityServices(); IStatAggregateService statAggregateService = new StatAggregateServiceImpl(); //Retrieving countries and its populations Dictionary <string, int> populationResults = statAggregateService.GetCountryPopulations(); helperServices.PrintDictionary(populationResults); Console.ReadKey(); }