public async Task <List <ReportEntity> > byWeekRecursive(long idCompany, long?idWeek) { if (!_weekRepository.Exist(idWeek)) { idWeek = (await _weekRepository.Current()).Id; } var example = await db.Where(r => r.Company.ParentId == idCompany && r.WeekId == idWeek).OrderBy(r => r.CompanyId).ToListAsync(); var childern = await _companyRepository.ChildrenOf(idCompany); foreach (CompanyEntity companyEntity in childern) { var returned = await this.byWeekRecursive(companyEntity.Id, idWeek); example = example.Concat(returned).ToList(); } return(example); }
public async Task <IActionResult> GetCompanyChildren(long id) { var children = await companyRepo.ChildrenOf(id); return(new OkObjectResult(children.Select(c => new CompanyResult(c)))); }