public async Task <int> DeleteAsync(int resourcePoolId) { var resourcePool = await GetByIdAsync(resourcePoolId); if (resourcePool == null) { return(0); } ResourcePoolStore.Remove(resourcePool); return(await Context.SaveChangesAsync()); }
public async Task <ResourcePool> GetByIdAsync(int resourcePoolId, bool live = true, params Expression <Func <ResourcePool, object> >[] includeProperties) { // Main query var query = ResourcePoolStore.AsQueryable().Where(entity => entity.Id == resourcePoolId); // Filter deleted records if (live) { query = query.Where(entity => !entity.DeletedOn.HasValue); } // Include properties foreach (var includeProperty in includeProperties) { query = query.Include(includeProperty); } // Return return(await query.SingleOrDefaultAsync()); }
public async Task <int> InsertAsync(ResourcePool entity) { ResourcePoolStore.Add(entity); return(await Context.SaveChangesAsync()); }