Exemplo n.º 1
0
        public async Task <T> Create(T entity)
        {
            using (FierceStukCloudDbContext context = _contextFactory.CreateDbContext(null))
            {
                EntityEntry <T> createdResult = await context.Set <T>().AddAsync(entity);

                await context.SaveChangesAsync();

                return(createdResult.Entity);
            }
        }
Exemplo n.º 2
0
        public async Task <T> Update(Guid guid, T entity)
        {
            using (FierceStukCloudDbContext context = _contextFactory.CreateDbContext(null))
            {
                entity.Id = guid;

                context.Set <T>().Update(entity);
                await context.SaveChangesAsync();

                return(entity);
            }
        }
Exemplo n.º 3
0
        public async Task <bool> Delete(Guid guid)
        {
            using (FierceStukCloudDbContext context = _contextFactory.CreateDbContext(null))
            {
                T entity = await context.Set <T>().FirstOrDefaultAsync(e => e.Id == guid);

                context.Set <T>().Remove(entity);

                await context.SaveChangesAsync();

                return(true);
            }
        }