// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, TraderDbContext context) { context.Database.Migrate(); 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.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "TraderService v1")); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public async Task <IEnumerable <Account> > GetAll() { using (TraderDbContext context = _context.CreateDbContext()) { IEnumerable <Account> entity = await context.Accounts.Include(a => a.AssetTransactions).ToListAsync(); return(entity); } }
public async Task <Account> Get(int Id) { using (TraderDbContext context = _context.CreateDbContext()) { Account entity = await context.Accounts.Include(a => a.AssetTransactions).FirstOrDefaultAsync(e => e.id == Id); return(entity); } }
public void Setup() { var options = new DbContextOptionsBuilder <TraderDbContext>() .UseSqlServer(Startup.ConnectionString) .Options; this.context = new TraderDbContext(options); this.repository = new CounterpartyRepository(this.context); }
public async Task <IEnumerable <T> > GetAll() { using (TraderDbContext context = _context.CreateDbContext()) { IEnumerable <T> entity = await context.Set <T>().ToListAsync(); return(entity); } }
public async Task <T> Get(int Id) { using (TraderDbContext context = _context.CreateDbContext()) { T entity = await context.Set <T>().FirstOrDefaultAsync(e => e.id == Id); return(entity); } }
public async Task <T> Update(int id, T entity) { using (TraderDbContext context = _context.CreateDbContext()) { entity.id = id; context.Set <T>().Update(entity); await context.SaveChangesAsync(); return(entity); } }
public async Task <T> Create(T entity) { using (TraderDbContext context = _context.CreateDbContext()) { EntityEntry <T> createEntity = await context.Set <T>().AddAsync(entity); await context.SaveChangesAsync(); return(createEntity.Entity); } }
public async Task <bool> Delete(int id) { using (TraderDbContext context = _context.CreateDbContext()) { T entity = await context.Set <T>().FirstOrDefaultAsync(e => e.id == id); context.Set <T>().Remove(entity); await context.SaveChangesAsync(); return(true); } }
public GenericDataService(TraderDbContext traderDbContext) { _traderDbContext = traderDbContext; _dbSet = _traderDbContext.Set <T>(); }
public TraderController(TraderDbContext context) { _context = context; }
public UnitOfWork(TraderDbContext context) { this.context = context; this.lazyCounterparyRepository = new Lazy <ICounterpartyRepository>(() => new CounterpartyRepository(context)); this.lazyTradeRepository = new Lazy <ITradeRepository>(() => new TradeRepository(context)); }