From 45b07a0069e66e87b5f2766a822aad4fe3e073e7 Mon Sep 17 00:00:00 2001 From: RossClark01 Date: Mon, 18 Nov 2024 22:31:34 -0500 Subject: [PATCH 1/2] Added API for determining if an RA is checked in --- Gordon360/Controllers/HousingController.cs | 21 +++++++++ Gordon360/Documentation/Gordon360.xml | 53 ++++++++++++++++++---- Gordon360/Services/HousingService.cs | 9 ++++ Gordon360/Services/ServiceInterfaces.cs | 2 + 4 files changed, 75 insertions(+), 10 deletions(-) diff --git a/Gordon360/Controllers/HousingController.cs b/Gordon360/Controllers/HousingController.cs index 8b3d7ce01..c556dfa4e 100644 --- a/Gordon360/Controllers/HousingController.cs +++ b/Gordon360/Controllers/HousingController.cs @@ -530,6 +530,27 @@ public async Task>> GetOnCallRAAllHal } } + /// + /// Checks if an RA is currently on call. + /// + /// The ID of the RA + /// True if the RA is on call, false otherwise + [HttpGet("is-on-call/{raId}")] + public async Task IsRAOnCall([FromRoute] string raId) + { + try + { + var isOnCall = await housingService.IsRAOnCallAsync(raId); + + return Ok(new { IsOnCall = isOnCall }); + } + catch (Exception ex) + { + return StatusCode(500, $"Internal server error: {ex.Message}"); + } + } + + } diff --git a/Gordon360/Documentation/Gordon360.xml b/Gordon360/Documentation/Gordon360.xml index 05d8fc483..c04a39e76 100644 --- a/Gordon360/Documentation/Gordon360.xml +++ b/Gordon360/Documentation/Gordon360.xml @@ -331,7 +331,7 @@ The ID of the hall. The resident's room number. - Returns the RA's ID if found, otherwise null. + Returns the RA's details if found, otherwise null. @@ -351,19 +351,35 @@ Returns a list of all assignments + + + Sets or updates an RA's preferred contact method + + The ID of the RA + The contact method (e.g., "Phone", "Teams") + True if the contact method was successfully set + + + + Retrieves the preferred contact information for a Resident Advisor (RA) based on their contact preference. + If the RA has a contact preference set, it will return either their phone number or a Microsoft Teams link + with their email embedded. If no preference exists, the method defaults to returning the RA's phone number. + + The ID of the Resident Advisor (RA) whose contact information is being requested. + A string containing the preferred contact information (phone number or Teams link) or a default + phone number if no preference is set. - Checks an RA in + Gets the on-call RAs for all halls. - The viewmodel object of the RA checking in - true if ra checked in succesfully + The RAs on call - + - Gets the ID of the on-call RA for a specified hall. + Checks if an RA is currently on call. - The ID of the hall - The ID of the on-call RA, or a 404 if no RA is on call + The ID of the RA + True if the RA is on call, false otherwise @@ -1964,7 +1980,7 @@ The ID of the hall. The resident's room number. - Returns the RA's ID if found, otherwise null. + Returns the RA's details if found, otherwise throws an exception. @@ -1984,12 +2000,29 @@ Returns a list of all assignments + + + Sets or updates an RA's preferred contact method + + The ID of the RA + The contact method (e.g., "Phone", "Teams") + True if the contact method was successfully set + + + + Retrieves the preferred contact information for a Resident Advisor (RA) based on their contact preference. + If the RA has a contact preference set, it will return either their phone number or a Microsoft Teams link + with their email embedded. If no preference exists, the method defaults to returning the RA's phone number. + + The ID of the Resident Advisor (RA) whose contact information is being requested. + A string containing the preferred contact information (phone number or Teams link) or a default + phone number if no preference is set. Checks an RA in The viewmodel object of the RA checking in - true if ra checked in succesfully + true if RA checked in successfully diff --git a/Gordon360/Services/HousingService.cs b/Gordon360/Services/HousingService.cs index 4377bc565..d913efa69 100644 --- a/Gordon360/Services/HousingService.cs +++ b/Gordon360/Services/HousingService.cs @@ -862,6 +862,15 @@ public async Task> GetOnCallRAAllHallsAsync() return onCallRAs; } + public async Task IsRAOnCallAsync(string raId) + { + // Check if the RA is currently on call + var isOnCall = await context.RA_On_Call + .AnyAsync(ra => ra.Ra_ID == raId && ra.Check_out_time == null); + + return isOnCall; + } + diff --git a/Gordon360/Services/ServiceInterfaces.cs b/Gordon360/Services/ServiceInterfaces.cs index 316ff46d3..587c4bbd9 100644 --- a/Gordon360/Services/ServiceInterfaces.cs +++ b/Gordon360/Services/ServiceInterfaces.cs @@ -237,6 +237,8 @@ public interface IHousingService Task RA_CheckinAsync(RA_On_CallViewModel checkin); Task GetOnCallRAAsync(string hallId); Task> GetOnCallRAAllHallsAsync(); + Task IsRAOnCallAsync(string raId); + } public interface IAcademicCheckInService From 161617f947ff70e4327872cde20645b80a8411f1 Mon Sep 17 00:00:00 2001 From: RossClark01 Date: Tue, 19 Nov 2024 14:15:08 -0500 Subject: [PATCH 2/2] Updated on call to return the RD name as well as the RA photo url. RD_Info now joined into on call view with proper building code --- Gordon360/Controllers/HousingController.cs | 5 -- Gordon360/Documentation/Gordon360.xml | 74 +++++++++++-------- Gordon360/Models/CCT/Context/CCTContext.cs | 1 + .../Models/CCT/Housing/Current_On_Call.cs | 9 +++ Gordon360/Models/CCT/Housing/RD_Info.cs | 10 +++ .../Housing/RA_On_Call_GetViewModel.cs | 2 + Gordon360/Services/HousingService.cs | 4 +- 7 files changed, 67 insertions(+), 38 deletions(-) diff --git a/Gordon360/Controllers/HousingController.cs b/Gordon360/Controllers/HousingController.cs index 4a186edaf..eccd162c6 100644 --- a/Gordon360/Controllers/HousingController.cs +++ b/Gordon360/Controllers/HousingController.cs @@ -592,11 +592,6 @@ public async Task>> GetOnCallRAAllHal return StatusCode(500, $"Internal server error: {ex.Message}"); } } - catch (Exception ex) - { - return StatusCode(500, $"Internal server error: {ex.Message}"); - } -} /// /// Checks if an RA is currently on call. diff --git a/Gordon360/Documentation/Gordon360.xml b/Gordon360/Documentation/Gordon360.xml index c04a39e76..289f625ec 100644 --- a/Gordon360/Documentation/Gordon360.xml +++ b/Gordon360/Documentation/Gordon360.xml @@ -296,12 +296,11 @@ The ViewModel that contains the hall ID and room range The created Hall_Assignment_Ranges object - + - Creates a new status event for an RA schedule + Retrieves all room ranges. - The ViewModel that contains the Schedule ID and RA ID - The created RA_Status_Schedule object + A list of room ranges. @@ -318,6 +317,12 @@ The ID of the RA to assign The created RA_Assigned_Ranges object + + + Retrieves the list of all assignments. + + Returns a list of all assignments + Deletes an RA range assignment @@ -333,24 +338,12 @@ The resident's room number. Returns the RA's details if found, otherwise null. - - - Retrieves all room ranges. - - A list of room ranges. - Retrieves a list of all RAs. Returns a list of RA_Students containing information about each RA - - - Retrieves the list of all assignments. - - Returns a list of all assignments - Sets or updates an RA's preferred contact method @@ -361,25 +354,34 @@ - Retrieves the preferred contact information for a Resident Advisor (RA) based on their contact preference. + Retrieves the preferred contact information for an RA based on their contact preference. If the RA has a contact preference set, it will return either their phone number or a Microsoft Teams link with their email embedded. If no preference exists, the method defaults to returning the RA's phone number. - The ID of the Resident Advisor (RA) whose contact information is being requested. + The ID of the RA whose contact information is being requested. A string containing the preferred contact information (phone number or Teams link) or a default phone number if no preference is set. + + + + Creates a new status event for an RA schedule + + The ViewModel that contains the Schedule ID and RA ID + The created RA_Status_Schedule object + - Gets the on-call RAs for all halls. + Checks an RA in - The RAs on call + The viewmodel object of the RA checking in + true if RA checked in successfully - + - Checks if an RA is currently on call. + Gets the ID of the on-call RA for a specified hall. - The ID of the RA - True if the RA is on call, false otherwise + The ID of the hall + The ID of the on-call RA, or a 404 if no RA is on call @@ -387,6 +389,13 @@ The RAs on call + + + Checks if an RA is currently on call. + + The ID of the RA + True if the RA is on call, false otherwise + Create a new error log item to be added to database The error message containing all required and relevant information @@ -2010,19 +2019,13 @@ - Retrieves the preferred contact information for a Resident Advisor (RA) based on their contact preference. + Retrieves the preferred contact information for an RA based on their contact preference. If the RA has a contact preference set, it will return either their phone number or a Microsoft Teams link with their email embedded. If no preference exists, the method defaults to returning the RA's phone number. - The ID of the Resident Advisor (RA) whose contact information is being requested. + The ID of the RA whose contact information is being requested. A string containing the preferred contact information (phone number or Teams link) or a default phone number if no preference is set. - - - Checks an RA in - - The viewmodel object of the RA checking in - true if RA checked in successfully @@ -2031,6 +2034,13 @@ The ID of the hall The ID of the on-call RA, or null if no RA is currently on call + + + Checks an RA in + + The viewmodel object of the RA checking in + true if RA checked in successfully + Gets the on-call RAs for all halls. diff --git a/Gordon360/Models/CCT/Context/CCTContext.cs b/Gordon360/Models/CCT/Context/CCTContext.cs index d7f0a7f77..8559eb904 100644 --- a/Gordon360/Models/CCT/Context/CCTContext.cs +++ b/Gordon360/Models/CCT/Context/CCTContext.cs @@ -582,6 +582,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { entity.ToView("RD_Info", "Housing"); + entity.Property(e => e.BuildingCode).IsFixedLength(); entity.Property(e => e.HallName).IsFixedLength(); }); diff --git a/Gordon360/Models/CCT/Housing/Current_On_Call.cs b/Gordon360/Models/CCT/Housing/Current_On_Call.cs index de67c70ad..c9323e1fe 100644 --- a/Gordon360/Models/CCT/Housing/Current_On_Call.cs +++ b/Gordon360/Models/CCT/Housing/Current_On_Call.cs @@ -36,6 +36,11 @@ public partial class Current_On_Call [Unicode(false)] public string RD_Email { get; set; } + [Required] + [StringLength(101)] + [Unicode(false)] + public string RD_Name { get; set; } + [Required] [StringLength(81)] [Unicode(false)] @@ -45,4 +50,8 @@ public partial class Current_On_Call [StringLength(81)] [Unicode(false)] public string RD_Profile_Link { get; set; } + + [StringLength(86)] + [Unicode(false)] + public string RA_Photo { get; set; } } \ No newline at end of file diff --git a/Gordon360/Models/CCT/Housing/RD_Info.cs b/Gordon360/Models/CCT/Housing/RD_Info.cs index 0bfb3c1c8..bdbf13777 100644 --- a/Gordon360/Models/CCT/Housing/RD_Info.cs +++ b/Gordon360/Models/CCT/Housing/RD_Info.cs @@ -15,6 +15,11 @@ public partial class RD_Info [Unicode(false)] public string HallName { get; set; } + [Required] + [StringLength(5)] + [Unicode(false)] + public string BuildingCode { get; set; } + [Column("RD Email")] [StringLength(50)] [Unicode(false)] @@ -22,4 +27,9 @@ public partial class RD_Info [StringLength(10)] public string RDId { get; set; } + + [Required] + [StringLength(101)] + [Unicode(false)] + public string RDName { get; set; } } \ No newline at end of file diff --git a/Gordon360/Models/ViewModels/Housing/RA_On_Call_GetViewModel.cs b/Gordon360/Models/ViewModels/Housing/RA_On_Call_GetViewModel.cs index 5303cde79..6e226a0c0 100644 --- a/Gordon360/Models/ViewModels/Housing/RA_On_Call_GetViewModel.cs +++ b/Gordon360/Models/ViewModels/Housing/RA_On_Call_GetViewModel.cs @@ -14,4 +14,6 @@ public class RA_On_Call_GetViewModel public string RD_Email { get; set; } public string RA_Profile_Link { get; set; } public string RD_Profile_Link { get; set; } + public string RD_Name { get; set; } + public string RA_Photo { get; set; } } \ No newline at end of file diff --git a/Gordon360/Services/HousingService.cs b/Gordon360/Services/HousingService.cs index 542e14fbb..2cc5ff8a4 100644 --- a/Gordon360/Services/HousingService.cs +++ b/Gordon360/Services/HousingService.cs @@ -970,7 +970,9 @@ public async Task> GetOnCallRAAllHallsAsync() Check_in_time = oncall.Check_in_time, // Check-in time RD_Email = oncall.RD_Email, // RD's email RA_Profile_Link = oncall.RA_Profile_Link, // RA's profile link - RD_Profile_Link = oncall.RD_Profile_Link // RD's profile link + RD_Profile_Link = oncall.RD_Profile_Link, // RD's profile link + RD_Name = oncall.RD_Name, + RA_Photo = oncall.RA_Photo }) .ToListAsync();