Example #1
0
        private void GetDataFromDbButton_Click(object sender, RoutedEventArgs e)
        {
            var cbrDbContext = new CbrDb();

            cbrDbContext.OpenConnection(_dbConnectionString);

            CurrenciesGrid.ItemsSource = cbrDbContext.GetAllValuteAsList();

            cbrDbContext.CloseConnection();
        }
Example #2
0
        private bool SaveDataToDb(IEnumerable <CurrencyRateModel> currencyRate)
        {
            var cbrDbContext = new CbrDb();

            cbrDbContext.OpenConnection(_dbConnectionString);

            if (!cbrDbContext.CleanCurrencyRateTable())
            {
                cbrDbContext.CloseConnection();
                return(false);
            }

            if (currencyRate.Any(valute => !cbrDbContext.InsertCurrencyRate(valute)))
            {
                cbrDbContext.CloseConnection();
                return(false);
            }

            cbrDbContext.CloseConnection();
            return(true);
        }