forked from ddrilling/AsbCloudServer
Изменение модели
1. Добавил новые сущности: уведомление, категория уведомления, способ отправки уведомления 2. Добавил DTO для новых сущностей 3. Накатил миграцию 4. Поправил DbContext
This commit is contained in:
parent
0fbc54e715
commit
d1555cc67b
17
AsbCloudApp/Data/NotificationCategoryDto.cs
Normal file
17
AsbCloudApp/Data/NotificationCategoryDto.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace AsbCloudApp.Data;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO категории уведомления
|
||||||
|
/// </summary>
|
||||||
|
public class NotificationCategoryDto : IId
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Id категории
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Название категории
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
}
|
59
AsbCloudApp/Data/NotificationDto.cs
Normal file
59
AsbCloudApp/Data/NotificationDto.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Data;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO уведомлений
|
||||||
|
/// </summary>
|
||||||
|
public class NotificationDto : IId
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Id уведомления
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Id получателя уведомления
|
||||||
|
/// </summary>
|
||||||
|
public int IdUser { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Id способа отправки уведомления
|
||||||
|
/// </summary>
|
||||||
|
public int IdNotificationTransport { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Id категории уведомления
|
||||||
|
/// </summary>
|
||||||
|
public int IdNotificationCategory { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Заголовок уведомления
|
||||||
|
/// </summary>
|
||||||
|
public string Title { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Текст уведомления
|
||||||
|
/// </summary>
|
||||||
|
public string Subject { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Время жизни уведомления
|
||||||
|
/// </summary>
|
||||||
|
public TimeSpan TimeToLife { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Дата отправки уведомления
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? SentDateAtUtc { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO способа доставки уведомления
|
||||||
|
/// </summary>
|
||||||
|
public NotificationTransportDto NotificationTransport { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO категории уведомления
|
||||||
|
/// </summary>
|
||||||
|
public NotificationCategoryDto NotificationCategory { get; set; } = null!;
|
||||||
|
}
|
17
AsbCloudApp/Data/NotificationTransportDto.cs
Normal file
17
AsbCloudApp/Data/NotificationTransportDto.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
namespace AsbCloudApp.Data;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// DTO способа доставки уведомления
|
||||||
|
/// </summary>
|
||||||
|
public class NotificationTransportDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Id способа доставки уведомления
|
||||||
|
/// </summary>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Название способа доставки
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
}
|
8378
AsbCloudDb/Migrations/20230707112234_Add_Notification.Designer.cs
generated
Normal file
8378
AsbCloudDb/Migrations/20230707112234_Add_Notification.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
175
AsbCloudDb/Migrations/20230707112234_Add_Notification.cs
Normal file
175
AsbCloudDb/Migrations/20230707112234_Add_Notification.cs
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Migrations
|
||||||
|
{
|
||||||
|
public partial class Add_Notification : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "id_category",
|
||||||
|
table: "t_help_page",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
comment: "Id категории файла",
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "integer",
|
||||||
|
oldComment: "id категории файла");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "t_notification_category",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
name = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_t_notification_category", x => x.id);
|
||||||
|
},
|
||||||
|
comment: "Категории уведомлений");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "t_notification_transport",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
name = table.Column<string>(type: "text", nullable: false, comment: "Название способа доставки уведомлений")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_t_notification_transport", x => x.id);
|
||||||
|
},
|
||||||
|
comment: "Способ доставки уведомлений");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "t_notification",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
id_user = table.Column<int>(type: "integer", nullable: false, comment: "Id получателя"),
|
||||||
|
id_notification_transport = table.Column<int>(type: "integer", nullable: false, comment: "Id способа доставки уведомления"),
|
||||||
|
id_notification_category = table.Column<int>(type: "integer", nullable: false, comment: "Id категории уведомления"),
|
||||||
|
title = table.Column<string>(type: "text", nullable: false, comment: "Заголовок уведомления"),
|
||||||
|
subject = table.Column<string>(type: "text", nullable: false, comment: "Текст уведомления"),
|
||||||
|
time_to_life = table.Column<TimeSpan>(type: "interval", nullable: false, comment: "Время жизни уведомления"),
|
||||||
|
sent_date_at_utc = table.Column<DateTime>(type: "timestamp with time zone", nullable: true, comment: "Дата отправки уведомления")
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_t_notification", x => x.id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_t_notification_t_notification_category_id_notification_cate~",
|
||||||
|
column: x => x.id_notification_category,
|
||||||
|
principalTable: "t_notification_category",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_t_notification_t_notification_transport_id_notification_tra~",
|
||||||
|
column: x => x.id_notification_transport,
|
||||||
|
principalTable: "t_notification_transport",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_t_notification_t_user_id_user",
|
||||||
|
column: x => x.id_user,
|
||||||
|
principalTable: "t_user",
|
||||||
|
principalColumn: "id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
},
|
||||||
|
comment: "Уведомлений");
|
||||||
|
|
||||||
|
migrationBuilder.InsertData(
|
||||||
|
table: "t_notification_category",
|
||||||
|
columns: new[] { "id", "name" },
|
||||||
|
values: new object[] { 1, "Системные уведомления" });
|
||||||
|
|
||||||
|
migrationBuilder.InsertData(
|
||||||
|
table: "t_notification_transport",
|
||||||
|
columns: new[] { "id", "name" },
|
||||||
|
values: new object[] { 1, "SignalR" });
|
||||||
|
|
||||||
|
migrationBuilder.InsertData(
|
||||||
|
table: "t_permission",
|
||||||
|
columns: new[] { "id", "description", "name" },
|
||||||
|
values: new object[,]
|
||||||
|
{
|
||||||
|
{ 519, "Разрешение просматривать список контактов", "WellContact.get" },
|
||||||
|
{ 520, "Разрешение редактировать список контактов", "WellContact.edit" }
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.InsertData(
|
||||||
|
table: "t_relation_user_role_permission",
|
||||||
|
columns: new[] { "id_permission", "id_user_role" },
|
||||||
|
values: new object[,]
|
||||||
|
{
|
||||||
|
{ 519, 1 },
|
||||||
|
{ 520, 1 }
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_t_notification_id_notification_category",
|
||||||
|
table: "t_notification",
|
||||||
|
column: "id_notification_category");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_t_notification_id_notification_transport",
|
||||||
|
table: "t_notification",
|
||||||
|
column: "id_notification_transport");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_t_notification_id_user",
|
||||||
|
table: "t_notification",
|
||||||
|
column: "id_user");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "t_notification");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "t_notification_category");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "t_notification_transport");
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "t_relation_user_role_permission",
|
||||||
|
keyColumns: new[] { "id_permission", "id_user_role" },
|
||||||
|
keyValues: new object[] { 519, 1 });
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "t_relation_user_role_permission",
|
||||||
|
keyColumns: new[] { "id_permission", "id_user_role" },
|
||||||
|
keyValues: new object[] { 520, 1 });
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "t_permission",
|
||||||
|
keyColumn: "id",
|
||||||
|
keyValue: 519);
|
||||||
|
|
||||||
|
migrationBuilder.DeleteData(
|
||||||
|
table: "t_permission",
|
||||||
|
keyColumn: "id",
|
||||||
|
keyValue: 520);
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "id_category",
|
||||||
|
table: "t_help_page",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
comment: "id категории файла",
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "integer",
|
||||||
|
oldComment: "Id категории файла");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -989,7 +989,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.Property<int>("IdCategory")
|
b.Property<int>("IdCategory")
|
||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
.HasColumnName("id_category")
|
.HasColumnName("id_category")
|
||||||
.HasComment("id категории файла");
|
.HasComment("Id категории файла");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
@ -1152,6 +1152,122 @@ namespace AsbCloudDb.Migrations
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AsbCloudDb.Model.Notification", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("IdNotificationCategory")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id_notification_category")
|
||||||
|
.HasComment("Id категории уведомления");
|
||||||
|
|
||||||
|
b.Property<int>("IdNotificationTransport")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id_notification_transport")
|
||||||
|
.HasComment("Id способа доставки уведомления");
|
||||||
|
|
||||||
|
b.Property<int>("IdUser")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id_user")
|
||||||
|
.HasComment("Id получателя");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("SentDateAtUtc")
|
||||||
|
.HasColumnType("timestamp with time zone")
|
||||||
|
.HasColumnName("sent_date_at_utc")
|
||||||
|
.HasComment("Дата отправки уведомления");
|
||||||
|
|
||||||
|
b.Property<string>("Subject")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("subject")
|
||||||
|
.HasComment("Текст уведомления");
|
||||||
|
|
||||||
|
b.Property<TimeSpan>("TimeToLife")
|
||||||
|
.HasColumnType("interval")
|
||||||
|
.HasColumnName("time_to_life")
|
||||||
|
.HasComment("Время жизни уведомления");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("title")
|
||||||
|
.HasComment("Заголовок уведомления");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("IdNotificationCategory");
|
||||||
|
|
||||||
|
b.HasIndex("IdNotificationTransport");
|
||||||
|
|
||||||
|
b.HasIndex("IdUser");
|
||||||
|
|
||||||
|
b.ToTable("t_notification");
|
||||||
|
|
||||||
|
b.HasComment("Уведомлений");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AsbCloudDb.Model.NotificationCategory", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("name");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("t_notification_category");
|
||||||
|
|
||||||
|
b.HasComment("Категории уведомлений");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
Name = "Системные уведомления"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AsbCloudDb.Model.NotificationTransport", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("id");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text")
|
||||||
|
.HasColumnName("name")
|
||||||
|
.HasComment("Название способа доставки уведомлений");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("t_notification_transport");
|
||||||
|
|
||||||
|
b.HasComment("Способ доставки уведомлений");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
Name = "SignalR"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.OperationValue", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.OperationValue", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -7559,6 +7675,33 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.Navigation("Well");
|
b.Navigation("Well");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AsbCloudDb.Model.Notification", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("AsbCloudDb.Model.NotificationCategory", "NotificationCategory")
|
||||||
|
.WithMany("Notifications")
|
||||||
|
.HasForeignKey("IdNotificationCategory")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("AsbCloudDb.Model.NotificationTransport", "NotificationTransport")
|
||||||
|
.WithMany("Notifications")
|
||||||
|
.HasForeignKey("IdNotificationTransport")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("AsbCloudDb.Model.User", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("IdUser")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("NotificationCategory");
|
||||||
|
|
||||||
|
b.Navigation("NotificationTransport");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.OperationValue", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.OperationValue", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("AsbCloudDb.Model.WellOperationCategory", "OperationCategory")
|
b.HasOne("AsbCloudDb.Model.WellOperationCategory", "OperationCategory")
|
||||||
@ -8151,6 +8294,16 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.Navigation("Measures");
|
b.Navigation("Measures");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AsbCloudDb.Model.NotificationCategory", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Notifications");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("AsbCloudDb.Model.NotificationTransport", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Notifications");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.Permission", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.Permission", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("RelationUserRolePermissions");
|
b.Navigation("RelationUserRolePermissions");
|
||||||
|
@ -74,8 +74,10 @@ namespace AsbCloudDb.Model
|
|||||||
public static int ReferenceCount => referenceCount;
|
public static int ReferenceCount => referenceCount;
|
||||||
|
|
||||||
public DbSet<Faq> Faqs => Set<Faq>();
|
public DbSet<Faq> Faqs => Set<Faq>();
|
||||||
|
|
||||||
public DbSet<HelpPage> HelpPages => Set<HelpPage>();
|
public DbSet<HelpPage> HelpPages => Set<HelpPage>();
|
||||||
|
public DbSet<Notification> Notifications => Set<Notification>();
|
||||||
|
public DbSet<NotificationCategory> NotificationCategories => Set<NotificationCategory>();
|
||||||
|
public DbSet<NotificationTransport> NotificationTransports => Set<NotificationTransport>();
|
||||||
|
|
||||||
public AsbCloudDbContext() : base()
|
public AsbCloudDbContext() : base()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
namespace AsbCloudDb.Model.DefaultData;
|
||||||
|
|
||||||
|
public class EntityNotificationCategory : EntityFiller<NotificationCategory>
|
||||||
|
{
|
||||||
|
public override NotificationCategory[] GetData() => new NotificationCategory[]
|
||||||
|
{
|
||||||
|
new() { Id = 1, Name = "Системные уведомления" }
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
namespace AsbCloudDb.Model.DefaultData;
|
||||||
|
|
||||||
|
public class EntityNotificationTransport : EntityFiller<NotificationTransport>
|
||||||
|
{
|
||||||
|
public override NotificationTransport[] GetData() => new NotificationTransport[]
|
||||||
|
{
|
||||||
|
new() { Id = 1, Name = "SignalR" }
|
||||||
|
};
|
||||||
|
}
|
@ -68,6 +68,9 @@ namespace AsbCloudDb.Model
|
|||||||
DbSet<Record60> Record60 { get; }
|
DbSet<Record60> Record60 { get; }
|
||||||
DbSet<Record61> Record61 { get; }
|
DbSet<Record61> Record61 { get; }
|
||||||
DbSet<HelpPage> HelpPages { get; }
|
DbSet<HelpPage> HelpPages { get; }
|
||||||
|
DbSet<Notification> Notifications { get; }
|
||||||
|
DbSet<NotificationCategory> NotificationCategories { get; }
|
||||||
|
DbSet<NotificationTransport> NotificationTransports { get; }
|
||||||
|
|
||||||
DatabaseFacade Database { get; }
|
DatabaseFacade Database { get; }
|
||||||
|
|
||||||
|
44
AsbCloudDb/Model/Notification.cs
Normal file
44
AsbCloudDb/Model/Notification.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Model;
|
||||||
|
|
||||||
|
[Table("t_notification"), Comment("Уведомлений")]
|
||||||
|
public class Notification : IId
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[Column("id")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Column("id_user"), Comment("Id получателя")]
|
||||||
|
public int IdUser { get; set; }
|
||||||
|
|
||||||
|
[Column("id_notification_transport"), Comment("Id способа доставки уведомления")]
|
||||||
|
public int IdNotificationTransport { get; set; }
|
||||||
|
|
||||||
|
[Column("id_notification_category"), Comment("Id категории уведомления")]
|
||||||
|
public int IdNotificationCategory { get; set; }
|
||||||
|
|
||||||
|
[Column("title"), Comment("Заголовок уведомления")]
|
||||||
|
public string Title { get; set; } = null!;
|
||||||
|
|
||||||
|
[Column("subject"), Comment("Текст уведомления")]
|
||||||
|
public string Subject { get; set; } = null!;
|
||||||
|
|
||||||
|
[Column("time_to_life"), Comment("Время жизни уведомления")]
|
||||||
|
public TimeSpan TimeToLife { get; set; }
|
||||||
|
|
||||||
|
[Column("sent_date_at_utc"), Comment("Дата отправки уведомления")]
|
||||||
|
public DateTime? SentDateAtUtc { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(IdNotificationTransport))]
|
||||||
|
public virtual NotificationTransport NotificationTransport { get; set; } = null!;
|
||||||
|
|
||||||
|
[ForeignKey(nameof(IdNotificationCategory))]
|
||||||
|
public virtual NotificationCategory NotificationCategory { get; set; } = null!;
|
||||||
|
|
||||||
|
[ForeignKey(nameof(IdUser))]
|
||||||
|
public virtual User User { get; set; } = null!;
|
||||||
|
}
|
20
AsbCloudDb/Model/NotificationCategory.cs
Normal file
20
AsbCloudDb/Model/NotificationCategory.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Model;
|
||||||
|
|
||||||
|
[Table("t_notification_category"), Comment("Категории уведомлений")]
|
||||||
|
public class NotificationCategory : IId
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[Column("id")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Column("name")]
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
|
[InverseProperty(nameof(Notification.NotificationCategory))]
|
||||||
|
public virtual ICollection<Notification> Notifications { get; set; } = null!;
|
||||||
|
}
|
20
AsbCloudDb/Model/NotificationTransport.cs
Normal file
20
AsbCloudDb/Model/NotificationTransport.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Model;
|
||||||
|
|
||||||
|
[Table("t_notification_transport"), Comment("Способ доставки уведомлений")]
|
||||||
|
public class NotificationTransport : IId
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[Column("id")]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Column("name"), Comment("Название способа доставки уведомлений")]
|
||||||
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
|
[InverseProperty(nameof(Notification.NotificationTransport))]
|
||||||
|
public virtual ICollection<Notification> Notifications { get; set; } = null!;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user