Skip to content

Commit

Permalink
Added API to check RA Pref Contact Method
Browse files Browse the repository at this point in the history
  • Loading branch information
RossClark01 committed Dec 4, 2024
1 parent 87be1c4 commit 95144e6
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
25 changes: 25 additions & 0 deletions Gordon360/Controllers/HousingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,31 @@ public async Task<ActionResult<string>> GetRAContact(string raId)
}
}

/// <summary>
/// Retrieves the preferred contact method for an RA based on their contact preference.
/// </summary>
/// <param name="raId">The ID of the RA whose contact information is being requested.</param>
/// <returns>A string containing the preferred contact method (Teams or Phone).</returns>
[HttpGet("ra/contact/preference/{raId}")]
public async Task<ActionResult> 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}");
}
}


/// <summary>
/// Creates a new status event for an RA schedule
Expand Down
14 changes: 14 additions & 0 deletions Gordon360/Documentation/Gordon360.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gordon360/Models/CCT/Context/CCTContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
27 changes: 27 additions & 0 deletions Gordon360/Services/HousingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,33 @@ public async Task<string> GetPreferredContactAsync(string raId)
return defaultContact?.PhoneNumber ?? "Default phone number not found";
}

/// <summary>
/// Retrieves the preferred contact method for an RA based on their contact preference.
/// </summary>
/// <param name="raId">The ID of the RA whose contact information is being requested.</param>
/// <returns>An object containing the preferred contact method (Teams or Phone).</returns>
public async Task<object> 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"
};

}

/// <summary>
/// Gets the on-call RA's ID for specified hall.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions Gordon360/Services/ServiceInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ public interface IHousingService
Task<List<RA_Assigned_RangesViewModel>> GetRangeAssignmentsAsync();
Task<bool> SetPreferredContactMethodAsync(string raId, string preferredContactMethod);
Task<string> GetPreferredContactAsync(string raId);
Task<object> GetContactPreferenceAsync(string raId);
Task<bool> RA_CheckinAsync(RA_On_CallViewModel checkin);
Task<RA_On_Call_GetViewModel> GetOnCallRAAsync(string hallId);
Task<List<RA_On_Call_GetViewModel>> GetOnCallRAAllHallsAsync();
Expand Down

0 comments on commit 95144e6

Please sign in to comment.