Files
hamkadr/src/JobsMedical.Web/Pages/Shifts/Details.cshtml.cs
T
soroush.asadi eae38373b9
CI/CD / CI · dotnet build (push) Failing after 1m40s
CI/CD / Deploy · hamkadr (push) Has been skipped
Admin suite: monitoring dashboard, user management/ban, broadcast, reports, SMS test
- /Admin/Overview: platform monitoring stats (users by role, facilities, listings, applies, push subs, queue, reports, bans)
- /Admin/Users: search/filter + ban/unban (User.IsBanned + reason); banned users blocked at login
- /Admin/Broadcast: send announcement (in-app + web push) to all / staff / employers via NotificationService
- Reports: report button on shift/job detail → /report endpoint → /Admin/Reports (resolve/dismiss)
- Settings: 'send test SMS' button; admin cross-nav links; SMS API config already in place
- migration AdminBanReports; verified overview/users/broadcast/report persist

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-04 13:19:20 +03:30

81 lines
2.7 KiB
C#

using JobsMedical.Web.Data;
using JobsMedical.Web.Models;
using JobsMedical.Web.Services;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
namespace JobsMedical.Web.Pages.Shifts;
public class DetailsModel : PageModel
{
private readonly AppDbContext _db;
private readonly InterestService _interest;
public DetailsModel(AppDbContext db, InterestService interest)
{
_db = db;
_interest = interest;
}
public Shift? Shift { get; private set; }
public List<Shift> MoreAtFacility { get; private set; } = new();
// Set after the visitor taps "interested" — reveals the facility contact (handoff model).
public bool ShowContact { get; private set; }
public bool Saved { get; private set; }
public bool Reported { get; private set; }
public async Task<IActionResult> OnGetAsync(int id)
{
await LoadAsync(id);
if (Shift is null) return NotFound();
Reported = Request.Query["reported"] == "1";
await _interest.LogAsync(InterestEventType.View, id); // behavioral signal for recommendations
return Page();
}
public async Task<IActionResult> OnPostInterestAsync(int id)
{
await LoadAsync(id);
if (Shift is null) return NotFound();
await _interest.LogAsync(InterestEventType.Apply, id);
ShowContact = true; // MVP handoff: reveal contact. Records an Application once auth lands.
return Page();
}
public async Task<IActionResult> OnPostSaveAsync(int id)
{
await LoadAsync(id);
if (Shift is null) return NotFound();
await _interest.LogAsync(InterestEventType.Save, id);
Saved = true;
return Page();
}
public async Task<IActionResult> OnPostDismissAsync(int id)
{
await _interest.LogAsync(InterestEventType.Dismiss, id);
return RedirectToPage("/Shifts/Index"); // not interested → back to the list
}
private async Task LoadAsync(int id)
{
Shift = await _db.Shifts
.Include(s => s.Facility).ThenInclude(f => f.City)
.Include(s => s.Role)
.FirstOrDefaultAsync(s => s.Id == id);
if (Shift is not null)
{
var today = DateOnly.FromDateTime(DateTime.UtcNow);
MoreAtFacility = await _db.Shifts
.Include(s => s.Facility).ThenInclude(f => f.City)
.Include(s => s.Role)
.Where(s => s.FacilityId == Shift.FacilityId && s.Id != id
&& s.Status == ShiftStatus.Open && s.Date >= today)
.OrderBy(s => s.Date).Take(3).ToListAsync();
}
}
}