public async Task <bool> Delete(int id) { using (StockTraderDbContext CNTXT = _STDBCF.CreateDbContext()) { F DeletedEntity = await CNTXT.Set <F>().FirstOrDefaultAsync((f) => f.Id == id); CNTXT.Set <F>().Remove(DeletedEntity); await CNTXT.SaveChangesAsync(); return(true); } }
public async Task <F> GetOne(int id) { using (StockTraderDbContext CNTXT = _STDBCF.CreateDbContext()) { F GetEntity = await CNTXT.Set <F>().FirstOrDefaultAsync((f) => f.Id == id); return(GetEntity); } }
public async Task <IEnumerable <F> > GetAll() { using (StockTraderDbContext CNTXT = _STDBCF.CreateDbContext()) { IEnumerable <F> GetEntities = await CNTXT.Set <F>().ToListAsync(); return(GetEntities); } }
public async Task <F> Update(int id, F UpdatedEntity) { using (StockTraderDbContext CNTXT = _STDBCF.CreateDbContext()) { UpdatedEntity.Id = id; CNTXT.Set <F>().Update(UpdatedEntity); await CNTXT.SaveChangesAsync(); return(UpdatedEntity); } }
public async Task <F> Create(F entity) { using (StockTraderDbContext CNTXT = _STDBCF.CreateDbContext()) { var CreatedEntity = await CNTXT.Set <F>().AddAsync(entity); await CNTXT.SaveChangesAsync(); return(CreatedEntity.Entity); } }