diff --git a/Gordon360/Controllers/HousingController.cs b/Gordon360/Controllers/HousingController.cs index 7f76f0709..a1c53017f 100644 --- a/Gordon360/Controllers/HousingController.cs +++ b/Gordon360/Controllers/HousingController.cs @@ -515,6 +515,31 @@ public async Task> GetRAContact(string raId) } } + /// + /// Retrieves the preferred contact method for an RA based on their contact preference. + /// + /// The ID of the RA whose contact information is being requested. + /// A string containing the preferred contact method (Teams or Phone). + [HttpGet("ra/contact/preference/{raId}")] + public async Task GetRAPrefContact(string raId) + { + try + { + var Preference = await housingService.GetContactPreferenceAsync(raId); + + if (Preference == null) + { + return NotFound("RA preferred contact information not found."); + } + + return Ok(Preference); + } + catch (Exception ex) + { + return StatusCode(500, $"Internal server error: {ex.Message}"); + } + } + /// /// Creates a new status event for an RA schedule diff --git a/Gordon360/Documentation/Gordon360.xml b/Gordon360/Documentation/Gordon360.xml index 6616f30f9..45974f6e0 100644 --- a/Gordon360/Documentation/Gordon360.xml +++ b/Gordon360/Documentation/Gordon360.xml @@ -369,6 +369,13 @@ A string containing the preferred contact information (phone number or Teams link) or a default phone number if no preference is set. + + + Retrieves the preferred contact method for an RA based on their contact preference. + + The ID of the RA whose contact information is being requested. + A string containing the preferred contact method (Teams or Phone). + Creates a new status event for an RA schedule @@ -2041,6 +2048,13 @@ A string containing the preferred contact information (phone number or Teams link) or a default phone number if no preference is set. + + + Retrieves the preferred contact method for an RA based on their contact preference. + + The ID of the RA whose contact information is being requested. + An object containing the preferred contact method (Teams or Phone). + Gets the on-call RA's ID for specified hall. diff --git a/Gordon360/Models/CCT/Context/CCTContext.cs b/Gordon360/Models/CCT/Context/CCTContext.cs index e74052317..24abc734d 100644 --- a/Gordon360/Models/CCT/Context/CCTContext.cs +++ b/Gordon360/Models/CCT/Context/CCTContext.cs @@ -529,7 +529,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { entity.ToView("ParticipantView", "RecIM"); - entity.Property(e => e.Hall).IsFixedLength(); + entity.Property(e => e.Email).IsFixedLength(); entity.Property(e => e.SpecifiedGender).IsFixedLength(); }); diff --git a/Gordon360/Services/HousingService.cs b/Gordon360/Services/HousingService.cs index b27c0f26f..ed7ab6e26 100644 --- a/Gordon360/Services/HousingService.cs +++ b/Gordon360/Services/HousingService.cs @@ -923,6 +923,33 @@ public async Task GetPreferredContactAsync(string raId) return defaultContact?.PhoneNumber ?? "Default phone number not found"; } + /// + /// Retrieves the preferred contact method for an RA based on their contact preference. + /// + /// The ID of the RA whose contact information is being requested. + /// An object containing the preferred contact method (Teams or Phone). + public async Task GetContactPreferenceAsync(string raId) + { + // Check if there is a preferred contact method for the given RA + var contactPreference = await context.RA_Pref_Contact + .FirstOrDefaultAsync(cp => cp.Ra_ID == raId); + + if (contactPreference != null) + { + return new + { + PreferredContact = contactPreference.Pref_contact + }; + } + + // If no preference exists, return phone default as default method + return new + { + PreferredContact = "phone" + }; + + } + /// /// Gets the on-call RA's ID for specified hall. /// diff --git a/Gordon360/Services/ServiceInterfaces.cs b/Gordon360/Services/ServiceInterfaces.cs index ed9d4e2ff..b1911c0bd 100644 --- a/Gordon360/Services/ServiceInterfaces.cs +++ b/Gordon360/Services/ServiceInterfaces.cs @@ -237,6 +237,7 @@ public interface IHousingService Task> GetRangeAssignmentsAsync(); Task SetPreferredContactMethodAsync(string raId, string preferredContactMethod); Task GetPreferredContactAsync(string raId); + Task GetContactPreferenceAsync(string raId); Task RA_CheckinAsync(RA_On_CallViewModel checkin); Task GetOnCallRAAsync(string hallId); Task> GetOnCallRAAllHallsAsync();