Exemplo n.º 1
0
        public async Task <TEntity> Update(TEntity entity)
        {
            using (var dbContext = new raw2Context())
            {
                dbContext.Entry(entity).State = EntityState.Modified;
                await dbContext.SaveChangesAsync();

                return(entity);
            }
        }
Exemplo n.º 2
0
        public async Task <TEntity> Create(TEntity entity)
        {
            using (var dbContext = new raw2Context())
            {
                dbContext.Set <TEntity>().Add(entity);
                await dbContext.SaveChangesAsync();

                return(entity);
            }
        }
Exemplo n.º 3
0
        public async Task <bool> Delete(int id)
        {
            using (var dbContext = new raw2Context())
            {
                var entity = await dbContext.Set <TEntity>().FindAsync(id);

                if (entity == null)
                {
                    return(false);
                }

                dbContext.Set <TEntity>().Remove(entity);
                await dbContext.SaveChangesAsync();

                return(true);
            }
        }