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); } }
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); } }
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); } }