Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ra checkin api #1098

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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