Table of Contents

Class NotificationService

Namespace
UsluzionicaServer.Services
Assembly
UsluzionicaServer.dll

Centralni servis za in-app notifikacije.

SendAsync: snima notifikaciju u bazu i odmah je push-uje korisniku preko NotificationHub-a ("user-{userId}" SignalR grupa).

Svi ostali servisi koji triggeruju eventi (BookingService, ReviewService itd.) koriste ovaj servis umesto direktnog db.Notifications.Add().

public sealed class NotificationService
Inheritance
NotificationService
Inherited Members

Constructors

NotificationService(AppDbContext, IHubContext<NotificationHub>, ILogger<NotificationService>)

Centralni servis za in-app notifikacije.

SendAsync: snima notifikaciju u bazu i odmah je push-uje korisniku preko NotificationHub-a ("user-{userId}" SignalR grupa).

Svi ostali servisi koji triggeruju eventi (BookingService, ReviewService itd.) koriste ovaj servis umesto direktnog db.Notifications.Add().

Methods

GetAsync(string, int, int)

Vraća notifikacije korisnika — nepročitane prve, zatim ostale od najnovijeg. Max 50 po pozivu.

GetUnreadCountAsync(string)

Broj nepročitanih notifikacija — za badge na UI.

MarkAllReadAsync(string)

Označi sve nepročitane notifikacije kao pročitane.

MarkReadAsync(string, int)

Označi jednu notifikaciju kao pročitanu. Vraća false ako ne postoji.

SendAsync(string, NotificationKind, string, string, int?)

Snima notifikaciju u bazu i push-uje je korisniku u realnom vremenu. Ako korisnik nije online (nije konektovan na hub), notifikacija čeka u bazi i biće dostupna pri sledećem GET /api/notifications.