Skip to content

Commit

Permalink
modeling Levels in schools
Browse files Browse the repository at this point in the history
  • Loading branch information
VGA committed Feb 19, 2021
1 parent 5c523a2 commit 28022b3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
32 changes: 29 additions & 3 deletions src/graph/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,15 @@ public EducationConfig Config
return eduConfig;
}
}
public GraphGroup GetGroupFromDisplayName(string displayName)
{
if (useCache)
{
return graphGroups.Where(p => string.Compare(p.DisplayName, displayName, true) == 0).SingleOrDefault();
}

return null;
}

public async Task<GraphGroup> GetGroupFromAlias(string groupAlias)
{
Expand Down Expand Up @@ -729,9 +738,16 @@ async public Task<GraphGroup> GetGroupFromId(Guid groupId, bool useCache = true)
}
else
{
var group = await client.Groups.Request().Top(1).Select(SelectGroupClause).Filter($"id eq '{groupId}'").Expand("extensions").GetAsync();
if (group.Count > 0)
return group[0];
try
{
var group = await client.Groups.Request().Top(1).Select(SelectGroupClause).Filter($"id eq '{groupId}'").Expand("extensions").GetAsync();
if (group.Count > 0)
return group[0];
}
catch
{
return null;
}
}

return null;
Expand All @@ -758,6 +774,16 @@ public EducationUser GetEducationUserFromId(Guid userId)
return educationUsers.Where(p => new Guid(p.Id) == userId).Single();
}

public EducationUser GetEducationUserFromAlias(string alias)
{
if (educationUsers == null)
{
throw new Exception("educationUsers not initialized, please call Client.Connect with a flag to do so");
}

return educationUsers.Where(p => string.Compare(p.UserPrincipalName, alias, true) == 0).Single();
}

public bool ValidateUserType(string userType)
{
foreach (var ut in SchoolManager.UserTypes)
Expand Down
10 changes: 7 additions & 3 deletions src/graph/SchoolManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public static class SchoolManager

static SchoolManager()
{
levels.Add(new Level(Constants.LEVEL_INICIAL, new List<string>() { "julia.laplace" }));
levels.Add(new Level(Constants.LEVEL_PRIMARIA, new List<string>() { "monica.bassagaisteguy", "maria.veppo" }));
levels.Add(new Level(Constants.LEVEL_SECUNDARIA, new List<string>() { "mariana.dellape", "maria.lascano" }));
levels.Add(new Level(Constants.LEVEL_INICIAL, new List<string>() { "julia.laplace@ijmecitybell.edu.ar" }));
levels.Add(new Level(Constants.LEVEL_PRIMARIA, new List<string>() { "monica.bassagaisteguy@ijmecitybell.edu.ar", "maria.veppo@ijmecitybell.edu.ar", "[email protected]" }));
levels.Add(new Level(Constants.LEVEL_SECUNDARIA, new List<string>() { "mariana.dellape@ijmecitybell.edu.ar", "maria.lascano@ijmecitybell.edu.ar", "[email protected]" }));

// Inicial level
sections.Add(new Section("Amarilla {0} {1}", Constants.LEVEL_INICIAL, new List<string> { Constants.GRADE_FIRST }, allDivisions));
Expand Down Expand Up @@ -118,6 +118,10 @@ static SchoolManager()
// TODO IJME: missing ed. fisica 5to A? (there are 2, should be 3, one per trimester)
}

static public Level GetLevel(string level)
{
return levels.Where(p => string.Equals(level, p.Id, StringComparison.InvariantCultureIgnoreCase)).Single();
}
static public IEnumerable<Section> GetSections(string level)
{
return sections.Where(p => string.Equals(level, p.Level, StringComparison.InvariantCultureIgnoreCase));
Expand Down

0 comments on commit 28022b3

Please sign in to comment.