using System.ComponentModel.DataAnnotations; using Asp.Versioning; using Baya.Application.Features.Notifications.Commands.MarkAllRead; using Baya.Application.Features.Notifications.Commands.MarkNotificationRead; using Baya.Application.Features.Notifications.Queries.GetUnreadCount; using Baya.Application.Features.Notifications.Queries.ListMyNotifications; using Baya.Application.Models.Common; using Baya.Application.Models.Notifications; using Baya.WebFramework.Attributes; using Baya.WebFramework.BaseController; using Mediator; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Baya.Web.Api.Controllers.V1; [ApiVersion("1")] [ApiController] [Route("api/v{version:apiVersion}/[controller]")] [Authorize] [Display(Description = "The signed-in user's in-app notifications")] public sealed class NotificationsController(ISender sender) : BaseController { [HttpGet("[action]")] [ProducesOkApiResponseType>] public async Task GetNotifications([FromQuery] ListMyNotificationsQuery query, CancellationToken cancellationToken) => OperationResult(await sender.Send(query, cancellationToken)); [HttpGet("[action]")] [ProducesOkApiResponseType] public async Task GetUnreadCount(CancellationToken cancellationToken) => OperationResult(await sender.Send(new GetUnreadCountQuery(), cancellationToken)); [HttpPost("[action]")] [ProducesOkApiResponseType] public async Task MarkNotificationRead(MarkNotificationReadCommand command, CancellationToken cancellationToken) => OperationResult(await sender.Send(command, cancellationToken)); [HttpPost("[action]")] [ProducesOkApiResponseType] public async Task MarkAllRead(CancellationToken cancellationToken) => OperationResult(await sender.Send(new MarkAllReadCommand(), cancellationToken)); }