diff --git a/Gordon360/Controllers/HousingController.cs b/Gordon360/Controllers/HousingController.cs index f6ee9cae4..eccd162c6 100644 --- a/Gordon360/Controllers/HousingController.cs +++ b/Gordon360/Controllers/HousingController.cs @@ -593,5 +593,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 cece21a1d..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 @@ -331,13 +336,7 @@ The ID of the hall. The resident's room number. - Returns the RA's ID if found, otherwise null. - - - - Retrieves all room ranges. - - A list of room ranges. + Returns the RA's details if found, otherwise null. @@ -345,12 +344,6 @@ 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,19 +354,27 @@ - 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 + Checks an RA in The viewmodel object of the RA checking in - true if ra checked in succesfully + true if RA checked in successfully @@ -388,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 @@ -1981,7 +1989,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. @@ -2011,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 succesfully @@ -2032,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 f4241f3c2..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(); @@ -979,6 +981,15 @@ public async Task> GetOnCallRAAllHallsAsync() + 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 4e6fb085f..59ceb84c0 100644 --- a/Gordon360/Services/ServiceInterfaces.cs +++ b/Gordon360/Services/ServiceInterfaces.cs @@ -239,6 +239,8 @@ public interface IHousingService Task RA_CheckinAsync(RA_On_CallViewModel checkin); Task GetOnCallRAAsync(string hallId); Task> GetOnCallRAAllHallsAsync(); + Task IsRAOnCallAsync(string raId); + } public interface IAcademicCheckInService