10d4727bd5
- Notification entity + NotificationService: on publish, notify users whose saved prefs match the listing (role/city/+shift type); users with no preference aren't spammed - Wired into PostShift, PostJob, and Admin Review publish - 🔔 bell with unread count in the header (@inject) + /Me/Notifications page (mark-all-read on open) - Reliable in-app delivery (works in Iran without FCM); Web Push can ride the same records later - Verified: employee pref → employer posts matching shift → employee bell=۱ + 'شیفت جدید: پزشک عمومی' Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
24 lines
750 B
C#
24 lines
750 B
C#
using System.Security.Claims;
|
|
using JobsMedical.Web.Models;
|
|
using JobsMedical.Web.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
namespace JobsMedical.Web.Pages.Me;
|
|
|
|
[Authorize]
|
|
public class NotificationsModel : PageModel
|
|
{
|
|
private readonly NotificationService _svc;
|
|
public NotificationsModel(NotificationService svc) => _svc = svc;
|
|
|
|
public List<Notification> Items { get; private set; } = new();
|
|
|
|
public async Task OnGetAsync()
|
|
{
|
|
var uid = int.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)!);
|
|
Items = await _svc.ListAsync(uid); // capture read-state for display
|
|
await _svc.MarkAllReadAsync(uid); // opening the page clears the bell
|
|
}
|
|
}
|