// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.ConfigureExceptionHandler(); // app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseReactDevelopmentServer(npmScript: "start"); } }); using (var dbContext = new ForexQuotationDBContext(new DbContextOptionsBuilder <ForexQuotationDBContext>().UseSqlServer(Configuration.GetConnectionString("ForexQuotationDBConnection")).Options)) { dbContext.Database.EnsureCreated(); var countryCallingCode = dbContext.CountryCallingCodes.FirstOrDefaultAsync().Result; if (countryCallingCode == null) { dbContext.CountryCallingCodes.Add(new Data.Model.CountryCallingCode { Code = "61" }); } var currency = dbContext.Currencies.FirstOrDefaultAsync().Result; if (currency == null) { dbContext.Currencies.Add(new Data.Model.Currency { Code = "AUD", Name = "Australian Dollar (AUD)" }); dbContext.Currencies.Add(new Data.Model.Currency { Code = "USD", Name = "United States Dollar (USD)" }); } var quotation = dbContext.Quotations.FirstOrDefaultAsync().Result; if (quotation == null) { dbContext.Quotations.Add(new Data.Model.Quotation { FirstName = "Tom", LastName = "Hanks", Email = "*****@*****.**", Phone = "+61460606060", FromCurrency = new Data.Model.Currency { Code = "AUD" }, ToCurrency = new Data.Model.Currency { Code = "USD" }, Amount = 10000, OFXCustomerRate = 0.72M, OFXCustomerAmount = 7200, CreatedDate = DateTime.Now }); dbContext.Quotations.Add(new Data.Model.Quotation { FirstName = "Rowan", LastName = "Atkinson", Email = "*****@*****.**", Phone = "+61460606060", FromCurrency = new Data.Model.Currency { Code = "AUD" }, ToCurrency = new Data.Model.Currency { Code = "USD" }, Amount = 20000, OFXCustomerRate = 0.73M, OFXCustomerAmount = 14600, CreatedDate = DateTime.Now }); } dbContext.SaveChanges(); } }
public CurrencyService(ForexQuotationDBContext dbContext) { _dbContext = dbContext; }
public QuotationService(ForexQuotationDBContext dbContext, ICurrencyService currencyService, IOFXAPIProxy ofxAPIProxy) { _dbContext = dbContext; _currencyService = currencyService; _ofxAPIProxy = ofxAPIProxy; }
public CountryCallingCodeService(ForexQuotationDBContext dbContext) { _dbContext = dbContext; }