Fixed error with group creation

This commit is contained in:
2026-04-28 11:12:55 +01:00
parent f523986475
commit 28d98d9e93
2 changed files with 4 additions and 1 deletions
@@ -2,6 +2,7 @@
using BeReadyBackend.Models;
using BeReadyBackend.Repositories;
using BeReadyBackend.Services;
using BeReadyBackend.Specifications.Groups;
using BeReadyBackend.Specifications.Users;
using FastEndpoints;
using Group = BeReadyBackend.Models.Group;
@@ -54,6 +55,6 @@ public class CreateGroupEndpoint(
group.UserGroups?.Add(userGroup);
await userGroupsRepository.AddRangeAsync(group.UserGroups!, ct);
await Send.NoContentAsync(ct);
await Send.OkAsync(await groupsRepository.ProjectToSingleAsync<GetGroupDto>(new GetGroupByIdSpec(group.Id), ct), ct);
}
}
@@ -59,6 +59,8 @@ public class EntityToDtoMappings : Profile
.ForMember(dest => dest.Users, opt => opt.MapFrom(src => src.UserGroups))
.ForMember(dest => dest.Messages, opt => opt.MapFrom(src => src.Messages));
CreateMap<Group, GetGroupDto>();
CreateMap<Message, GetMessageDto>()
.ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.User!.Username));