Files
UniVerse/backend/UniVerse.Infrastructure/Data/Configurations/UserNotificationConfiguration.cs
serega404 b0a4a6d259
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 9s
🚀 Create and publish a Docker image / Build & publish backend image (push) Successful in 26s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Successful in 19s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Successful in 8s
feat: добавил личные уведомления для пользователей
Реализовал хранение, получение и отметку прочитанными пользовательских уведомлений. Обновил фронтенд для отображения и управления уведомлениями в профиле студента.
2026-05-12 23:54:55 +03:00

30 lines
1.2 KiB
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using UniVerse.Domain.Entities;
namespace UniVerse.Infrastructure.Data.Configurations;
public class UserNotificationConfiguration : IEntityTypeConfiguration<UserNotification>
{
public void Configure(EntityTypeBuilder<UserNotification> builder)
{
builder.ToTable("user_notifications");
builder.HasKey(n => n.Id);
builder.Property(n => n.Id).HasColumnName("id");
builder.Property(n => n.UserId).HasColumnName("user_id");
builder.Property(n => n.Type).HasColumnName("type").HasMaxLength(50).IsRequired();
builder.Property(n => n.Title).HasColumnName("title").HasMaxLength(255).IsRequired();
builder.Property(n => n.Body).HasColumnName("body").HasMaxLength(1000).IsRequired();
builder.Property(n => n.IsRead).HasColumnName("is_read").HasDefaultValue(false);
builder.Property(n => n.CreatedAt).HasColumnName("created_at").HasDefaultValueSql("NOW()");
builder.HasOne(n => n.User)
.WithMany(u => u.Notifications)
.HasForeignKey(n => n.UserId)
.OnDelete(DeleteBehavior.Cascade);
builder.HasIndex(n => new { n.UserId, n.CreatedAt });
}
}