Fin création des groupes
This commit is contained in:
@@ -41,26 +41,9 @@ public class CreateGroupDiscussionEndpoint(KnotsDbContext db) : Endpoint<CreateG
|
||||
|
||||
int totalMembers = targets.Count + 1;
|
||||
|
||||
// 1. Créer le groupe SANS DiscussionId pour l'instant
|
||||
Models.Group group = new()
|
||||
{
|
||||
Name = req.GroupName,
|
||||
MembersAmount = totalMembers,
|
||||
DiscussionId = 0, // temporaire
|
||||
GroupUsers = targets
|
||||
.Select(t => new GroupUser { UserId = t.Id })
|
||||
.Append(new GroupUser { UserId = currentUserId })
|
||||
.ToList()
|
||||
};
|
||||
|
||||
db.Groups.Add(group);
|
||||
await db.SaveChangesAsync(ct); // group.Id disponible
|
||||
|
||||
// 2. Créer la discussion avec le GroupId
|
||||
Models.Discussion discussion = new()
|
||||
{
|
||||
IsGroup = true,
|
||||
GroupId = group.Id,
|
||||
UserDiscussions = targets
|
||||
.Select(t => new UserDiscussion { UserId = t.Id })
|
||||
.Append(new UserDiscussion { UserId = currentUserId })
|
||||
@@ -70,8 +53,23 @@ public class CreateGroupDiscussionEndpoint(KnotsDbContext db) : Endpoint<CreateG
|
||||
db.Discussions.Add(discussion);
|
||||
await db.SaveChangesAsync(ct); // discussion.Id disponible
|
||||
|
||||
// 3. Mettre à jour le DiscussionId sur le groupe
|
||||
group.DiscussionId = discussion.Id;
|
||||
|
||||
Models.Group group = new()
|
||||
{
|
||||
Name = req.GroupName,
|
||||
MembersAmount = totalMembers,
|
||||
DiscussionId = discussion.Id,
|
||||
GroupUsers = targets
|
||||
.Select(t => new GroupUser { UserId = t.Id })
|
||||
.Append(new GroupUser { UserId = currentUserId })
|
||||
.ToList()
|
||||
};
|
||||
|
||||
db.Groups.Add(group);
|
||||
await db.SaveChangesAsync(ct); // group.Id disponible
|
||||
|
||||
|
||||
discussion.GroupId = group.Id;
|
||||
await db.SaveChangesAsync(ct);
|
||||
|
||||
await SendOkAsync(new GetDiscussionDto
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Knots")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4e06dc5f235e9c9c699b247eb56dccf3eeed81f8")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f1cdc5de19a96d553f0eaf2fbe65392602c54f85")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Knots")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Knots")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
@@ -1 +1 @@
|
||||
45989a1b023b2a60770db7a1baceef9c56c487cca0e44ae9d0d75cdde668b8cc
|
||||
0618e480c1221c208fb53c91259f81c85675af45b5772bccc9fee873e927c02b
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user