From 40cc1495178d829a48ec2396a1b18c6d96905a92 Mon Sep 17 00:00:00 2001 From: amos-cha Date: Fri, 21 Jul 2023 13:37:36 -0400 Subject: [PATCH 1/2] Update variable to be less convoluted --- Gordon360/Controllers/RecIM/ActivitiesController.cs | 3 ++- Gordon360/Services/RecIM/ActivityService.cs | 4 ++-- Gordon360/Services/ServiceInterfaces.cs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Gordon360/Controllers/RecIM/ActivitiesController.cs b/Gordon360/Controllers/RecIM/ActivitiesController.cs index 0aa07e2be..f40172d16 100644 --- a/Gordon360/Controllers/RecIM/ActivitiesController.cs +++ b/Gordon360/Controllers/RecIM/ActivitiesController.cs @@ -31,7 +31,8 @@ public ActionResult> GetActivities([FromQ { if ( active is bool isActive) { - var res = _activityService.GetActiveActivities(isActive); + bool completed = !isActive; + var res = _activityService.GetActivitiesByCompletion(completed); return Ok(res); } diff --git a/Gordon360/Services/RecIM/ActivityService.cs b/Gordon360/Services/RecIM/ActivityService.cs index 630bdc41e..61fe981c4 100644 --- a/Gordon360/Services/RecIM/ActivityService.cs +++ b/Gordon360/Services/RecIM/ActivityService.cs @@ -88,9 +88,9 @@ public IEnumerable GetActivities() }); return activities; } - public IEnumerable GetActiveActivities(bool isActive) + public IEnumerable GetActivitiesByCompletion(bool isCompleted) { - return GetActivities().Where(a => !a.Completed == isActive); + return GetActivities().Where(a => a.Completed == isCompleted); } public ActivityExtendedViewModel? GetActivityByID(int activityID) diff --git a/Gordon360/Services/ServiceInterfaces.cs b/Gordon360/Services/ServiceInterfaces.cs index 1463231d1..7241da63d 100644 --- a/Gordon360/Services/ServiceInterfaces.cs +++ b/Gordon360/Services/ServiceInterfaces.cs @@ -326,7 +326,7 @@ public interface IActivityService IEnumerable? GetActivityLookup(string type); IEnumerable GetActivities(); ActivityExtendedViewModel? GetActivityByID(int activityID); - IEnumerable GetActiveActivities(bool isActive); + IEnumerable GetActivitiesByCompletion(bool isActive); Task UpdateActivityAsync(int activytID, ActivityPatchViewModel updatedActivity); Task PostActivityAsync(ActivityUploadViewModel newActivity); Task AddParticipantActivityInvolvementAsync(string username, int activityID, int privTypeID, bool isFreeAgent); From 0608f670d19572e8ad61d675439301953742a2ad Mon Sep 17 00:00:00 2001 From: amos-cha Date: Fri, 21 Jul 2023 13:43:17 -0400 Subject: [PATCH 2/2] Shorten get_user_gender statement --- Gordon360/Services/RecIM/ParticipantService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gordon360/Services/RecIM/ParticipantService.cs b/Gordon360/Services/RecIM/ParticipantService.cs index 1dcbc05c0..ad411a127 100644 --- a/Gordon360/Services/RecIM/ParticipantService.cs +++ b/Gordon360/Services/RecIM/ParticipantService.cs @@ -275,10 +275,10 @@ public bool GetParticipantIsCustom(string username) public async Task PostParticipantAsync(string username, int? statusID) { // Find gender - - var student = _context.Student.Where(s => s.AD_Username == username).FirstOrDefault(); - var facstaff = _context.FacStaff.Where(fs => fs.AD_Username == username).FirstOrDefault(); - string user_gender = student?.Gender ?? facstaff?.Gender ?? "U"; + string user_gender = + _context.Student.FirstOrDefault(s => s.AD_Username == username)?.Gender ?? + _context.FacStaff.FirstOrDefault(fs => fs.AD_Username == username)?.Gender ?? + "U"; await _context.Participant.AddAsync(new Participant {