Skip to content

Commit

Permalink
Merge pull request #1098 from RossClark01/RA-Checkin-API
Browse files Browse the repository at this point in the history
Ra checkin api
  • Loading branch information
RossClark01 authored Nov 19, 2024
2 parents 60e2805 + 161617f commit 608b4a8
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 30 deletions.
22 changes: 22 additions & 0 deletions Gordon360/Controllers/HousingController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -593,5 +593,27 @@ public async Task<ActionResult<List<RA_On_Call_GetViewModel>>> GetOnCallRAAllHal
}
}

/// <summary>
/// Checks if an RA is currently on call.
/// </summary>
/// <param name="raId">The ID of the RA</param>
/// <returns>True if the RA is on call, false otherwise</returns>
[HttpGet("is-on-call/{raId}")]
public async Task<IActionResult> 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}");
}
}




}
67 changes: 38 additions & 29 deletions Gordon360/Documentation/Gordon360.xml

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

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

Expand Down
9 changes: 9 additions & 0 deletions Gordon360/Models/CCT/Housing/Current_On_Call.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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; }
}
10 changes: 10 additions & 0 deletions Gordon360/Models/CCT/Housing/RD_Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,21 @@ 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)]
public string RD_Email { get; set; }

[StringLength(10)]
public string RDId { get; set; }

[Required]
[StringLength(101)]
[Unicode(false)]
public string RDName { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
13 changes: 12 additions & 1 deletion Gordon360/Services/HousingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,9 @@ public async Task<List<RA_On_Call_GetViewModel>> 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();

Expand All @@ -979,6 +981,15 @@ public async Task<List<RA_On_Call_GetViewModel>> GetOnCallRAAllHallsAsync()



public async Task<bool> 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;
}




Expand Down
2 changes: 2 additions & 0 deletions Gordon360/Services/ServiceInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ public interface IHousingService
Task<bool> RA_CheckinAsync(RA_On_CallViewModel checkin);
Task<RA_On_Call_GetViewModel> GetOnCallRAAsync(string hallId);
Task<List<RA_On_Call_GetViewModel>> GetOnCallRAAllHallsAsync();
Task<bool> IsRAOnCallAsync(string raId);

}

public interface IAcademicCheckInService
Expand Down

0 comments on commit 608b4a8

Please sign in to comment.