public async Task <IActionResult> PutTraderModel(Guid id, TraderModel traderModel) { if (id != traderModel.TraderId) { return(BadRequest()); } _context.Entry(traderModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TraderModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <T> Create(T entity) { var result = await _dbSet.AddAsync(entity); await _traderDbContext.SaveChangesAsync(); return(result.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); } }