public void Configure(IApplicationBuilder app, IWebHostEnvironment env, TaxDbContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); context.Database.Migrate(); }
public VatRate GetVateRate(TaxDbContext db, string category) { var group = db.VatGroups.Include(x => x.VatRate).FirstOrDefault(x => x.Key == category); if (group != null) { return(group.VatRate); } return(null); }
public TaxesController(TaxDbContext taxDbContext) { _context = taxDbContext; if (_context.TaxZones.Count() == 0) { _context.TaxZones.Add(new TaxZone { ZipCode = 84037, TaxRate = (decimal)0.1 }); _context.SaveChanges(); } }
public virtual void SetupDatabase(IServiceCollection services) { var connectionString = Configuration.GetConnectionString("DefaultConnection"); var options = new DbContextOptionsBuilder <TaxDbContext>(); options.UseSqlServer(connectionString); using (var context = new TaxDbContext(options.Options)) { context.Database.Migrate(); } services.AddDbContext <TaxDbContext>(o => o.UseSqlServer(connectionString)); }
public override void SetupDatabase(IServiceCollection services) { var connection = new SqliteConnection($"DataSource=file:Tax-Db{Guid.NewGuid()}?mode=memory"); var options = new DbContextOptionsBuilder <TaxDbContext>() .UseSqlite(connection).Options; using (var context = new TaxDbContext(options)) { context.Database.OpenConnection(); context.Database.EnsureCreated(); } services.AddTransient(x => new TaxDbContext(options)); }
public UserTaxRepository(TaxDbContext context) { _context = context; }
public TaxCalculatorService(TaxDbContext context) { _context = context; }
public TaxRepository(TaxDbContext taxContext) { this._taxContext = taxContext; }
public TaxesController(ILogger <TaxesController> logger, TaxDbContext context) { _logger = logger; _context = context; }
public VatRate GetDefault(TaxDbContext db) { var group = db.VatRates.FirstOrDefault(x => x.IsDefault == true); return(group); }