public bool Process(WalutyDBContext context)
        {
            DateTime currentDate         = DateTime.Now;
            string   fullPathToDirectory = Path.Combine(Directory.GetParent(Environment.CurrentDirectory).Parent.FullName,
                                                        _fileFolderName,
                                                        currentDate.ToString("ddMMyyyy"));
            bool             downloaderResult = false;
            bool             unzipperResult   = false;
            bool             updateResult     = false;
            IList <Currency> loadedCurrencies = new List <Currency>();

            downloaderResult = _downloader.DownloadFilesAsync(_databaseZipFileLink, _databaseContentFileLink, fullPathToDirectory, currentDate, _contentFileName, _databaseFileName).Result;
            unzipperResult   = _unzipper.UnzipFile(_databaseFileName, fullPathToDirectory);

            if (downloaderResult && unzipperResult)
            {
                loadedCurrencies = _loader.GetListOfAllCurrencies(fullPathToDirectory);

                updateResult = UpdateCurrencies(loadedCurrencies, context);

                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
 public static void InitialiseDB(WalutyDBContext context, ILoader loader)
 {
     if (!context.Currencies.Any() && !context.CurrencyInfos.Any())
     {
         context.AddRange(loader.GetListOfAllCurrencies(loader.PathToDirectory));
         context.AddRange(loader.LoadCurrencyInformation(loader.PathToDirectory));
         context.SaveChanges();
     }
 }