public async Task <IEnumerable <Proxy> > Reload(int groupId) { List <ProxyEntity> entities; // Only allow reloading one group at a time (multiple threads should // not use the same DbContext at the same time). await semaphore.WaitAsync(); try { if (groupId == -1) { entities = await proxyRepo.GetAll().ToListAsync(); } else { var group = await proxyGroupsRepo.Get(groupId); entities = await proxyRepo.GetAll() .Where(p => p.Group.Id == groupId) .ToListAsync(); } } finally { semaphore.Release(); } var proxyFactory = new ProxyFactory(); return(entities.Select(e => proxyFactory.FromEntity(e))); }
public async Task <IEnumerable <Proxy> > Reload(int groupId) { List <ProxyEntity> entities; if (groupId == -1) { entities = await proxyRepo.GetAll().ToListAsync(); } else { var group = await proxyGroupsRepo.Get(groupId); entities = await proxyRepo.GetAll() .Where(p => p.Group.Id == groupId) .ToListAsync(); } var proxyFactory = new ProxyFactory(); return(entities.Select(e => proxyFactory.FromEntity(e))); }