- NotificationsController.cs with 5 endpoints:
* GET /synergy/notifications - list with unreadOnly filter
* GET /synergy/notifications/unread-count - badge count
* POST /synergy/notifications/mark-read - single or bulk
* POST /synergy/notifications/send - player or broadcast
* DELETE /synergy/notifications/{id} - delete by player
- Notification entity added to RR3DbContext (FK to Users, cascade delete)
- NotificationDto, NotificationsResponse, MarkReadRequest,
SendNotificationRequest models added to ApiModels.cs
- Migration AddNotificationsTable applied
- Build: 0 errors, 0 warnings
- All 5 endpoints tested and working
Server now: 75/73 core endpoints (notifications + admin delete = 76)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
81 lines
3.5 KiB
C#
81 lines
3.5 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace RR3CommunityServer.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddNotificationsTable : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Notifications",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "INTEGER", nullable: false)
|
|
.Annotation("Sqlite:Autoincrement", true),
|
|
UserId = table.Column<int>(type: "INTEGER", nullable: false),
|
|
Type = table.Column<string>(type: "TEXT", nullable: false),
|
|
Title = table.Column<string>(type: "TEXT", nullable: false),
|
|
Message = table.Column<string>(type: "TEXT", nullable: false),
|
|
IsRead = table.Column<bool>(type: "INTEGER", nullable: false),
|
|
CreatedAt = table.Column<DateTime>(type: "TEXT", nullable: false),
|
|
ExpiresAt = table.Column<DateTime>(type: "TEXT", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Notifications", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Notifications_Users_UserId",
|
|
column: x => x.UserId,
|
|
principalTable: "Users",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "TimeTrials",
|
|
keyColumn: "Id",
|
|
keyValue: 1,
|
|
columns: new[] { "EndDate", "StartDate" },
|
|
values: new object[] { new DateTime(2026, 3, 3, 0, 7, 51, 537, DateTimeKind.Utc).AddTicks(6445), new DateTime(2026, 2, 24, 0, 7, 51, 537, DateTimeKind.Utc).AddTicks(6442) });
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "TimeTrials",
|
|
keyColumn: "Id",
|
|
keyValue: 2,
|
|
columns: new[] { "EndDate", "StartDate" },
|
|
values: new object[] { new DateTime(2026, 3, 3, 0, 7, 51, 537, DateTimeKind.Utc).AddTicks(6454), new DateTime(2026, 2, 24, 0, 7, 51, 537, DateTimeKind.Utc).AddTicks(6453) });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Notifications_UserId",
|
|
table: "Notifications",
|
|
column: "UserId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Notifications");
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "TimeTrials",
|
|
keyColumn: "Id",
|
|
keyValue: 1,
|
|
columns: new[] { "EndDate", "StartDate" },
|
|
values: new object[] { new DateTime(2026, 3, 2, 1, 55, 50, 958, DateTimeKind.Utc).AddTicks(35), new DateTime(2026, 2, 23, 1, 55, 50, 958, DateTimeKind.Utc).AddTicks(32) });
|
|
|
|
migrationBuilder.UpdateData(
|
|
table: "TimeTrials",
|
|
keyColumn: "Id",
|
|
keyValue: 2,
|
|
columns: new[] { "EndDate", "StartDate" },
|
|
values: new object[] { new DateTime(2026, 3, 2, 1, 55, 50, 958, DateTimeKind.Utc).AddTicks(43), new DateTime(2026, 2, 23, 1, 55, 50, 958, DateTimeKind.Utc).AddTicks(43) });
|
|
}
|
|
}
|
|
}
|