Add news feature with CRUD operations and real-time notifications
- Implemented news management functionality, allowing admins to create, read, update, and delete news posts. - Introduced a new SignalR event for broadcasting news updates to all connected clients. - Updated API documentation to include new endpoints for news management. - Enhanced frontend with a dedicated news page and admin interface for managing news posts. - Added necessary localization for news-related terms in both Russian and English.
This commit is contained in:
1 parent
bea2b5fcf7
commit
b6637a1c03
47 files changed
+2523
-9
No files matched your search
@@ -0,0 +1,21 @@
|
||||
using PnvPanel.Application.Common.Interfaces;
|
||||
using PnvPanel.Application.Common.Messaging;
|
||||
using PnvPanel.Application.Common.Models;
|
||||
using PnvPanel.Application.News;
|
||||
using PnvPanel.Domain.News;
|
||||
|
||||
namespace PnvPanel.Application.Admin.News;
|
||||
|
||||
public sealed class CreatePostCommandHandler(IAppDbContext dbContext, IRealtimeNotifier notifier)
|
||||
: ICommandHandler<CreatePostCommand, Result<NewsPostDto>>
|
||||
{
|
||||
public async Task<Result<NewsPostDto>> Handle(CreatePostCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
var post = NewsPost.Create(command.Title, command.Body);
|
||||
dbContext.NewsPosts.Add(post);
|
||||
|
||||
await notifier.NotifyNewsPublishedAsync(post.Id, post.Title, post.CreatedAt, cancellationToken);
|
||||
|
||||
return Result.Success(NewsPostDto.FromDomain(post));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user