public History(Form1 parent, CurrencyRateRepository currencyRateRepository) { this.parent = parent; _currencyRateRepository = currencyRateRepository; InitializeComponent(); InitializeData(); }
public Form1(BankRepository bankRepository, CurrencyRepository currencyRepository, CurrencyRateRepository currencyRateRepository) { _bankRepository = bankRepository; _currencyRepository = currencyRepository; _currencyRateRepository = currencyRateRepository; InitializeComponent(); InitializeData(); history = new History(this, currencyRateRepository); }
public CurrencyRateRepositoryTests(ITestOutputHelper output) { this.output = output; var dbOptions = new DbContextOptionsBuilder <CurrencyRateContext>() .UseInMemoryDatabase(databaseName: "TestCurrencyRates") .Options; currencyRateContext = new CurrencyRateContext(dbOptions); timeService = new ManagedTimeService(); currencyRateRepository = new CurrencyRateRepository(currencyRateContext, timeService); }
static void Main() { // List<User> users = Database.GetUsers(); // foreach (var user in users) // { // Console.WriteLine(user); // } var database = new Database(); var bankRepository = new BankRepository(database); var currencyRepository = new CurrencyRepository(database); var currencyRateRepository = new CurrencyRateRepository(database); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1(bankRepository, currencyRepository, currencyRateRepository)); }
private void InternalRun() { DateTime latestUpdated; var currencyList = GetCurrencyListFromWeb(out latestUpdated); Log.Info(string.Format("Currency list contains {0} items", currencyList.Count())); if (!DatabaseHasStoredCurrencyList) { Log.Info("Currency list store to DB started..."); StoreToDatabaseCurrencyList(currencyList); Log.Info("Currency list store to DB successfully completed!"); } var now = DateTime.Now.Date; var history = RetriveCurrencyHistoriesFromWeb(currencyList, now.AddYears(-1), now); CurrencyRateRepository.EnsureTransaction(() => { Log.Info(string.Format("Currency list with history data {0} items", history.Count())); if (history != null) { Log.Info("Store currency historical price started"); StoreToDatabaseCurrencyHistory(history); Log.Info("Store currency historical price successfully completed!"); } var latestData = _LastCurrencyRates.Select(pair => { var currencyName = pair.Key; var price = pair.Value; var data = new CurrencyHistoryData(currencyName); data.History.Add(new CurrencyHistoryItemData(latestUpdated, price)); return(data); } ); Log.Info("Store latest currency rates started"); StoreToDatabaseCurrencyHistory(latestData); Log.Info("Store latest currency rates successfully completed!"); }); }
private void StoreToDatabaseCurrencyHistory(IEnumerable <CurrencyHistoryData> history) { foreach (var historyData in history) { var currencyName = historyData.CurrencyName; var currency = CurrencyRateRepository.GetCurrencyOrCreate(currencyName); foreach (var hdi in historyData.History.OrderBy(i => i.Date)) { var historyItem = new CurrencyRateHistory { CurrencyData = currency, Price = hdi.Price, Updated = hdi.Date }; currency.LastUpdated = hdi.Date; currency.Price = hdi.Price; CurrencyRateRepository.SaveHistoryItem(historyItem); } } }
public CurrencyRateService(CurrencyRateRepository currencyRateRepository, BankClientDataProvider bankClientDataProvider) { _currencyRateRepository = currencyRateRepository; _bankClientDataProvider = bankClientDataProvider; }
private bool IsDatabaseNotContainsHistory(string currencyName) { return(!CurrencyRateRepository.IsContainsHistory(currencyName)); }
private void StoreToDatabaseCurrencyList(IEnumerable <string> data) { CurrencyRateRepository.EnsureTransaction(() => data.ToList().ForEach(currencyName => CurrencyRateRepository.Save(new CurrencyData(currencyName)))); }
public void SetUp() { _session = CreateSession(); _currency = new CurrencyRateRepository(_session); }
public FreeAgentMarketplaceModelBuilder(MP_FreeAgentExpenseCategoryRepository freeAgentExpenseCategoryRepository, CurrencyRateRepository currencyRateRepository, ISession session) : base(session) { _currencyConverter = new CurrencyConvertor(currencyRateRepository); foreach (MP_FreeAgentExpenseCategory dbCategory in freeAgentExpenseCategoryRepository.GetAll()) { var category = new FreeAgentExpenseCategory { Id = dbCategory.Id, category_group = dbCategory.category_group, url = dbCategory.url, description = dbCategory.description, nominal_code = dbCategory.nominal_code, allowable_for_tax = dbCategory.allowable_for_tax, tax_reporting_name = dbCategory.tax_reporting_name, auto_sales_tax_rate = dbCategory.auto_sales_tax_rate }; _expenseCategories.Add(category.url, category); } }