Example #1
0
        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);
            }
        }
Example #2
0
        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);
            }
        }
Example #3
0
        public async Task <IEnumerable <F> > GetAll()
        {
            using (StockTraderDbContext CNTXT = _STDBCF.CreateDbContext())
            {
                IEnumerable <F> GetEntities = await CNTXT.Set <F>().ToListAsync();

                return(GetEntities);
            }
        }
Example #4
0
        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);
            }
        }
Example #5
0
        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);
            }
        }