Skip to content

Instantly share code, notes, and snippets.

@gzamudio
Created March 14, 2019 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gzamudio/615148ecfe6a6f7b92754e4abc8d2033 to your computer and use it in GitHub Desktop.
Save gzamudio/615148ecfe6a6f7b92754e4abc8d2033 to your computer and use it in GitHub Desktop.
private IEnumerable<Resource> GetSchoolGroupAccesedResources(int? schoolId, SchoolGroup schoolGroup, DateTime startingDate)
{
var schoolGroupResources = schoolGroup
.SchoolGroupPrograms
.SelectMany(sgp => sgp.EducationalProgram.EducationalProgramResources)
.Select(epr => epr.Resource)
.Where(r => r.UpdatedAt > startingDate);
IEnumerable<int> schoolUserIds = null;
if (schooId != null)
schoolUserIds = school.Teachers.Select(t => t.TeacherId).Concat(school.Managers.Select(m => m.ManagerId);
else
schoolUserIds = schoolGroup.Schools.SelectMany(s => s.Teachers).Select(t => t.TeacherId)
.Concat(schoolGroup.Schools.SelectMany(s => s.Managers).Select(m => m.ManagerId))
return schoolGroupResources.Where(r => r.ResourceAccesses.Any(ra => schoolUserIds.Contains(ra.UserId)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment