From 28022b33270eb11aa2a5f508bf63e864b0d582ba Mon Sep 17 00:00:00 2001 From: VGA Date: Thu, 18 Feb 2021 22:00:58 -0300 Subject: [PATCH] modeling Levels in schools --- src/graph/Client.cs | 32 +++++++++++++++++++++++++++++--- src/graph/SchoolManager.cs | 10 +++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/graph/Client.cs b/src/graph/Client.cs index 850b604..b8c4aaf 100644 --- a/src/graph/Client.cs +++ b/src/graph/Client.cs @@ -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 GetGroupFromAlias(string groupAlias) { @@ -729,9 +738,16 @@ async public Task 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; @@ -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) diff --git a/src/graph/SchoolManager.cs b/src/graph/SchoolManager.cs index c1ca84b..236cb3c 100644 --- a/src/graph/SchoolManager.cs +++ b/src/graph/SchoolManager.cs @@ -22,9 +22,9 @@ public static class SchoolManager static SchoolManager() { - levels.Add(new Level(Constants.LEVEL_INICIAL, new List() { "julia.laplace" })); - levels.Add(new Level(Constants.LEVEL_PRIMARIA, new List() { "monica.bassagaisteguy", "maria.veppo" })); - levels.Add(new Level(Constants.LEVEL_SECUNDARIA, new List() { "mariana.dellape", "maria.lascano" })); + levels.Add(new Level(Constants.LEVEL_INICIAL, new List() { "julia.laplace@ijmecitybell.edu.ar" })); + levels.Add(new Level(Constants.LEVEL_PRIMARIA, new List() { "monica.bassagaisteguy@ijmecitybell.edu.ar", "maria.veppo@ijmecitybell.edu.ar", "patriciosalas@ijmecitybell.onmicrosoft.com" })); + levels.Add(new Level(Constants.LEVEL_SECUNDARIA, new List() { "mariana.dellape@ijmecitybell.edu.ar", "maria.lascano@ijmecitybell.edu.ar", "patriciosalas@ijmecitybell.onmicrosoft.com" })); // Inicial level sections.Add(new Section("Amarilla {0} {1}", Constants.LEVEL_INICIAL, new List { Constants.GRADE_FIRST }, allDivisions)); @@ -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
GetSections(string level) { return sections.Where(p => string.Equals(level, p.Level, StringComparison.InvariantCultureIgnoreCase));