Files
Govor/Govor.Domain/Configurations/GroupMembershipConfiguration.cs
Artemy 2e9d7e625e Add primitive groups and required channel
Adds server-side group and channel management, private invitations, member moderation, avatar handling, and required-channel configuration. This change also introduces SignalR group profile/member notifications, updates registration to atomically join required channels, and adds EF migration and test coverage for group membership, permissions, and invitation expiry rules.
2026-10-04 10:35:07 +07:00

33 lines
1.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Govor.Domain.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Govor.Domain.Configurations;
public class GroupMembershipConfiguration : IEntityTypeConfiguration<GroupMembership>
{
public void Configure(EntityTypeBuilder<GroupMembership> builder)
{
builder.HasKey(e => e.Id);
builder.HasIndex(e => new { e.GroupId, e.UserId }).IsUnique();
builder.HasOne<Govor.Domain.Models.Users.User>().WithMany()
.HasForeignKey(e => e.UserId).OnDelete(DeleteBehavior.Cascade);
builder.Property(e => e.UserId).IsRequired();
builder.Property(e => e.GroupId).IsRequired();
builder.Property(e => e.InvitationId).IsRequired(false);
builder.HasOne(e => e.ChatGroup)
.WithMany(g => g.Members)
.HasForeignKey(e => e.GroupId)
.OnDelete(DeleteBehavior.Cascade);
// Optional: настройка связи с GroupInvitation
builder.HasOne<GroupInvitation>()
.WithMany()
.HasForeignKey(e => e.InvitationId)
.OnDelete(DeleteBehavior.SetNull);
}
}