Spaces:
Runtime error
Runtime error
Download TaskTrackingSystem.WebApi/Features/Notification/NotificationController.cs from Yuruyuruu/task-tracking-system: direct link, hf CLI and curl.
- Browser
- Download file 2.12 kB
-
https://huggingface.co/spaces/Yuruyuruu/task-tracking-system/resolve/main/TaskTrackingSystem.WebApi/Features/Notification/NotificationController.cs
- Command line
-
hf download hf://spaces/Yuruyuruu/task-tracking-system/TaskTrackingSystem.WebApi/Features/Notification/NotificationController.cs
-
curl -L -o NotificationController.cs https://huggingface.co/spaces/Yuruyuruu/task-tracking-system/resolve/main/TaskTrackingSystem.WebApi/Features/Notification/NotificationController.cs
2.12 kB
| using Microsoft.AspNetCore.Authorization; | |
| using Microsoft.AspNetCore.Mvc; | |
| using TaskTrackingSystem.Shared; | |
| using TaskTrackingSystem.WebApi.Infrastructure; | |
| namespace TaskTrackingSystem.WebApi.Features.Notification; | |
| [] | |
| [] | |
| [] | |
| public class NotificationController : ControllerBase | |
| { | |
| private readonly NotificationService _notificationService; | |
| public NotificationController(NotificationService notificationService) | |
| { | |
| _notificationService = notificationService; | |
| } | |
| [] | |
| public async Task<ActionResult<IEnumerable<TaskTrackingSystem.Shared.Models.Notification.NotificationDto>>> GetMine([FromQuery] int take = 10) | |
| { | |
| var userId = User.GetUserId(); | |
| if (userId <= 0) | |
| { | |
| return Unauthorized(); | |
| } | |
| var items = await _notificationService.GetRecentAsync(userId, take); | |
| return Ok(items); | |
| } | |
| [] | |
| public async Task<ActionResult<int>> GetUnreadCount() | |
| { | |
| var userId = User.GetUserId(); | |
| if (userId <= 0) | |
| { | |
| return Unauthorized(); | |
| } | |
| var count = await _notificationService.GetUnreadCountAsync(userId); | |
| return Ok(count); | |
| } | |
| [] | |
| public async Task<ActionResult<Result>> MarkRead(long id) | |
| { | |
| var userId = User.GetUserId(); | |
| if (userId <= 0) | |
| { | |
| return Unauthorized(Result.Failure("User is not authenticated.", 401)); | |
| } | |
| var result = await _notificationService.MarkReadAsync(userId, id); | |
| return StatusCode(result.StatusCode, result); | |
| } | |
| [] | |
| public async Task<ActionResult<Result<int>>> DeleteRead([FromQuery] DateTime? before = null) | |
| { | |
| var userId = User.GetUserId(); | |
| if (userId <= 0) | |
| { | |
| return Unauthorized(Result.Failure("User is not authenticated.", 401)); | |
| } | |
| var deletedCount = await _notificationService.DeleteReadNotificationsAsync(userId, before); | |
| return Ok(Result<int>.Success(deletedCount)); | |
| } | |
| } | |