Compare commits

...

2 Commits

Author SHA1 Message Date
Francesco Lorenzo D'Amico e66d95ec7a Save per entry for no duplicate data
Deploy Staging / deploy (push) Successful in 1m24s
2026-08-24 13:41:09 +02:00
Francesco Lorenzo D'Amico 28eb67c551 EF Migraion for making Contact Message required 2026-08-24 13:37:57 +02:00
3 changed files with 169 additions and 3 deletions
@@ -0,0 +1,125 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using RazorPagesMovie.Data;
#nullable disable
namespace RazorPagesMovie.Migrations
{
[DbContext(typeof(RazorPagesMovieContext))]
[Migration("20260821123359_MakeContactMessageSubjectRequired")]
partial class MakeContactMessageSubjectRequired
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.28")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("RazorPagesMovie.Models.AdminUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.HasKey("Id");
b.ToTable("AdminUser");
});
modelBuilder.Entity("RazorPagesMovie.Models.ContactMessage", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Message")
.IsRequired()
.HasMaxLength(5000)
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<bool>("NotificationSent")
.HasColumnType("bit");
b.Property<string>("Phone")
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<DateTime>("SentAt")
.HasColumnType("datetime2");
b.Property<string>("Subject")
.IsRequired()
.HasMaxLength(150)
.HasColumnType("nvarchar(150)");
b.HasKey("Id");
b.ToTable("ContactMessage");
});
modelBuilder.Entity("RazorPagesMovie.Models.Movie", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Genre")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("nvarchar(30)");
b.Property<decimal>("Price")
.HasColumnType("decimal(18, 2)");
b.Property<string>("Rating")
.IsRequired()
.HasMaxLength(5)
.HasColumnType("nvarchar(5)");
b.Property<DateTime>("ReleaseDate")
.HasColumnType("datetime2");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.HasKey("Id");
b.ToTable("Movie");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,42 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace RazorPagesMovie.Migrations
{
/// <inheritdoc />
public partial class MakeContactMessageSubjectRequired : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.Sql("UPDATE ContactMessage SET Subject = '' WHERE Subject IS NULL;");
migrationBuilder.AlterColumn<string>(
name: "Subject",
table: "ContactMessage",
type: "nvarchar(150)",
maxLength: 150,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(150)",
oldMaxLength: 150,
oldNullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Subject",
table: "ContactMessage",
type: "nvarchar(150)",
maxLength: 150,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(150)",
oldMaxLength: 150);
}
}
}
@@ -79,6 +79,7 @@ public class ContactMessageNotificationService : BackgroundService
if (response.IsSuccessStatusCode)
{
eintrag.NotificationSent = true;
await context.SaveChangesAsync(stoppingToken);
}
else
{
@@ -90,7 +91,5 @@ public class ContactMessageNotificationService : BackgroundService
_logger.LogError(ex, "Telegram-Versand fehlgeschlagen für ContactMessage {Id}", eintrag.Id);
}
}
await context.SaveChangesAsync(stoppingToken);
}
}