Compare commits
2 Commits
c3eed1f45e
...
747ad10090
| Author | SHA1 | Date | |
|---|---|---|---|
| 747ad10090 | |||
| 727494aab4 |
@@ -1,6 +1,7 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEndpoint_002ESend_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fc2fa49f697e4d07c58aa3f35484a5103de685287155db8b628f2cdce16b69_003FEndpoint_002ESend_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEndpoint_002ESend_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fc2fa49f697e4d07c58aa3f35484a5103de685287155db8b628f2cdce16b69_003FEndpoint_002ESend_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEndpoint_002ESetup_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003F656240c46e44c14018dc6190e77764a3404d76b559ed75474669c553eb6227dd_003FEndpoint_002ESetup_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEndpoint_002ESetup_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003F656240c46e44c14018dc6190e77764a3404d76b559ed75474669c553eb6227dd_003FEndpoint_002ESetup_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIHubClients_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fd6ae5218e3a0462f8a94591a77a902637b750_003Faf_003F6ad738e4_003FIHubClients_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIHubContext_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F731dbe51d65849048244493644b992cd78910_003Fda_003Fd14ae6ee_003FIHubContext_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIHubContext_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F731dbe51d65849048244493644b992cd78910_003Fda_003Fd14ae6ee_003FIHubContext_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARepositoryBaseOfT_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003F5023b5be698d783ffe9f42b2e944a85a7a66b61bc5e19c76c591036343fd16_003FRepositoryBaseOfT_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARepositoryBaseOfT_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003F5023b5be698d783ffe9f42b2e944a85a7a66b61bc5e19c76c591036343fd16_003FRepositoryBaseOfT_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARepositoryBaseOfT_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003F5023b5be698d783ffe9f42b2e944a85a7a66b61bc5e19c76c591036343fd16_003FRepositoryBaseOfT_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARepositoryBaseOfT_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E2_003Fresharper_002Dhost_003FSourcesCache_003F5023b5be698d783ffe9f42b2e944a85a7a66b61bc5e19c76c591036343fd16_003FRepositoryBaseOfT_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||||
|
|||||||
@@ -4,5 +4,4 @@ public class CreateMessageDto
|
|||||||
{
|
{
|
||||||
public int GroupId { get; set; }
|
public int GroupId { get; set; }
|
||||||
public string? Libelle { get; set; }
|
public string? Libelle { get; set; }
|
||||||
public DateTime SendDate { get; set; }
|
|
||||||
}
|
}
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
using BeReadyBackend.Models;
|
|
||||||
using BeReadyBackend.Repositories;
|
|
||||||
using BeReadyBackend.Specifications.Messages;
|
|
||||||
using FastEndpoints;
|
|
||||||
|
|
||||||
namespace BeReadyBackend.Endpoints.Messages;
|
|
||||||
|
|
||||||
public class DeleteMessageRequest
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int GroupId { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class DeleteMessageEndpoint(MessagesRepository messagesRepository) : Endpoint<DeleteMessageRequest>
|
|
||||||
{
|
|
||||||
public override void Configure()
|
|
||||||
{
|
|
||||||
Delete("/Messages/{@Id}/Groups/{@GroupId}/", x => new { x.Id, x.GroupId });
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task HandleAsync(DeleteMessageRequest req, CancellationToken ct)
|
|
||||||
{
|
|
||||||
Message? message = await messagesRepository.SingleOrDefaultAsync(new GetMessageByIdSpec(req.Id), ct);
|
|
||||||
|
|
||||||
if (message is null)
|
|
||||||
{
|
|
||||||
await Send.NotFoundAsync(ct);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await messagesRepository.DeleteAsync(message, ct);
|
|
||||||
await Send.NoContentAsync(ct);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,6 +4,7 @@ using BeReadyBackend.Models;
|
|||||||
using BeReadyBackend.Repositories;
|
using BeReadyBackend.Repositories;
|
||||||
using BeReadyBackend.Services;
|
using BeReadyBackend.Services;
|
||||||
using BeReadyBackend.Specifications.Groups;
|
using BeReadyBackend.Specifications.Groups;
|
||||||
|
using BeReadyBackend.Specifications.Messages;
|
||||||
using FastEndpoints;
|
using FastEndpoints;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using Group = System.Text.RegularExpressions.Group;
|
using Group = System.Text.RegularExpressions.Group;
|
||||||
@@ -34,10 +35,12 @@ public class SendMessageEndpoint(
|
|||||||
|
|
||||||
Message message = new();
|
Message message = new();
|
||||||
mapper.Map(req, message);
|
mapper.Map(req, message);
|
||||||
|
message.SendDate = DateTime.Now;
|
||||||
message.UserId = userService.GetUserIdFromToken();
|
message.UserId = userService.GetUserIdFromToken();
|
||||||
|
|
||||||
await messagesRepository.AddAsync(message, ct);
|
await messagesRepository.AddAsync(message, ct);
|
||||||
await hubContext.Clients.Group($"group-{req.GroupId}").SendAsync("ReceiveMessage", message, cancellationToken: ct);
|
GetMessageDto messageDto = await messagesRepository.ProjectToSingleAsync<GetMessageDto>(new GetMessageByIdSpec(message.Id), ct);
|
||||||
|
await hubContext.Clients.Group($"group-{req.GroupId}").SendAsync("ReceiveMessage", messageDto, cancellationToken: ct);
|
||||||
await Send.NoContentAsync(ct);
|
await Send.NoContentAsync(ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
using Microsoft.AspNetCore.SignalR;
|
using BeReadyBackend.DTO.Messages;
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
|
|
||||||
namespace BeReadyBackend.Hubs;
|
namespace BeReadyBackend.Hubs;
|
||||||
|
|
||||||
public class GroupHub : Hub
|
public class GroupHub : Hub
|
||||||
{
|
{
|
||||||
public async Task SendMessageToGroup(int groupId, string message)
|
public async Task SendMessageToGroup(int groupId, CreateMessageDto message)
|
||||||
{
|
{
|
||||||
await Clients.Group($"group-{groupId}").SendAsync("ReceiveMessage", message);
|
await Clients.Group($"group-{groupId}").SendAsync("ReceiveMessage", message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,6 @@ public class CreateMessageDtoValidator : Validator<CreateMessageDto>
|
|||||||
.MinimumLength(2)
|
.MinimumLength(2)
|
||||||
.WithMessage("Libelle must exceed 2 characters");
|
.WithMessage("Libelle must exceed 2 characters");
|
||||||
|
|
||||||
RuleFor(x => x.SendDate)
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("SendDate is required");
|
|
||||||
|
|
||||||
RuleFor(x => x.GroupId)
|
RuleFor(x => x.GroupId)
|
||||||
.NotEmpty()
|
.NotEmpty()
|
||||||
.WithMessage("GroupId is required")
|
.WithMessage("GroupId is required")
|
||||||
|
|||||||
Reference in New Issue
Block a user