Added endpoints to update verspakketten and add beoordeling. Added some validations and other tweaks
This commit is contained in:
@@ -13,6 +13,8 @@ public class LutraDbContext : DbContext, ILutraDbContext
|
||||
|
||||
public DbSet<Supermarkt> Supermarkten => Set<Supermarkt>();
|
||||
|
||||
public DbSet<Beoordeling> Beoordelingen => Set<Beoordeling>();
|
||||
|
||||
public DbSet<Verspakket> Verspaketten => Set<Verspakket>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
@@ -22,11 +24,19 @@ public class LutraDbContext : DbContext, ILutraDbContext
|
||||
modelBuilder.Entity<Beoordeling>()
|
||||
.ToTable("Beoordelingen");
|
||||
|
||||
modelBuilder.Entity<Verspakket>()
|
||||
.HasMany(v => v.Beoordelingen)
|
||||
.WithOne()
|
||||
.HasForeignKey(b => b.VerspakketId)
|
||||
.IsRequired();
|
||||
modelBuilder.Entity<Verspakket>(b =>
|
||||
{
|
||||
b.HasMany(v => v.Beoordelingen)
|
||||
.WithOne()
|
||||
.HasForeignKey(beo => beo.VerspakketId)
|
||||
.IsRequired();
|
||||
|
||||
b.ToTable(t =>
|
||||
{
|
||||
t.HasCheckConstraint("CK_Verspaketten_AantalPersonen", "\"AantalPersonen\" BETWEEN 1 AND 10");
|
||||
t.HasCheckConstraint("CK_Verspaketten_PrijsInCenten", "\"PrijsInCenten\" IS NULL OR \"PrijsInCenten\" >= 0");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
||||
|
||||
157
Lutra/Lutra.Infrastructure/Migrations/20260418173428_AddAantalPersonenCheckConstraint.Designer.cs
generated
Normal file
157
Lutra/Lutra.Infrastructure/Migrations/20260418173428_AddAantalPersonenCheckConstraint.Designer.cs
generated
Normal file
@@ -0,0 +1,157 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Lutra.Infrastructure.Sql;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lutra.Infrastructure.Sql.Migrations
|
||||
{
|
||||
[DbContext(typeof(LutraDbContext))]
|
||||
[Migration("20260418173428_AddAantalPersonenCheckConstraint")]
|
||||
partial class AddAantalPersonenCheckConstraint
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Lutra.Domain.Entities.Beoordeling", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<bool>("Aanbevolen")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("CijferBereiden")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("CijferSmaak")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DeletedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("ModifiedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Tekst")
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("character varying(1024)");
|
||||
|
||||
b.Property<Guid>("VerspakketId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("VerspakketId");
|
||||
|
||||
b.ToTable("Beoordelingen", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lutra.Domain.Entities.Supermarkt", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DeletedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("ModifiedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Naam")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Supermarkten");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lutra.Domain.Entities.Verspakket", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("AantalPersonen")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DeletedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("ModifiedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Naam")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)");
|
||||
|
||||
b.Property<int?>("PrijsInCenten")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("SupermarktId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SupermarktId");
|
||||
|
||||
b.ToTable("Verspaketten", t =>
|
||||
{
|
||||
t.HasCheckConstraint("CK_Verspaketten_AantalPersonen", "\"AantalPersonen\" BETWEEN 1 AND 10");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lutra.Domain.Entities.Beoordeling", b =>
|
||||
{
|
||||
b.HasOne("Lutra.Domain.Entities.Verspakket", null)
|
||||
.WithMany("Beoordelingen")
|
||||
.HasForeignKey("VerspakketId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lutra.Domain.Entities.Verspakket", b =>
|
||||
{
|
||||
b.HasOne("Lutra.Domain.Entities.Supermarkt", "Supermarkt")
|
||||
.WithMany()
|
||||
.HasForeignKey("SupermarktId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Supermarkt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lutra.Domain.Entities.Verspakket", b =>
|
||||
{
|
||||
b.Navigation("Beoordelingen");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lutra.Infrastructure.Sql.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddAantalPersonenCheckConstraint : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddCheckConstraint(
|
||||
name: "CK_Verspaketten_AantalPersonen",
|
||||
table: "Verspaketten",
|
||||
sql: "\"AantalPersonen\" BETWEEN 1 AND 10");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropCheckConstraint(
|
||||
name: "CK_Verspaketten_AantalPersonen",
|
||||
table: "Verspaketten");
|
||||
}
|
||||
}
|
||||
}
|
||||
159
Lutra/Lutra.Infrastructure/Migrations/20260418174149_AddPrijsInCentenCheckConstraint.Designer.cs
generated
Normal file
159
Lutra/Lutra.Infrastructure/Migrations/20260418174149_AddPrijsInCentenCheckConstraint.Designer.cs
generated
Normal file
@@ -0,0 +1,159 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Lutra.Infrastructure.Sql;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lutra.Infrastructure.Sql.Migrations
|
||||
{
|
||||
[DbContext(typeof(LutraDbContext))]
|
||||
[Migration("20260418174149_AddPrijsInCentenCheckConstraint")]
|
||||
partial class AddPrijsInCentenCheckConstraint
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Lutra.Domain.Entities.Beoordeling", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<bool>("Aanbevolen")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<int>("CijferBereiden")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("CijferSmaak")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DeletedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("ModifiedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Tekst")
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("character varying(1024)");
|
||||
|
||||
b.Property<Guid>("VerspakketId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("VerspakketId");
|
||||
|
||||
b.ToTable("Beoordelingen", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lutra.Domain.Entities.Supermarkt", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DeletedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("ModifiedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Naam")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Supermarkten");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lutra.Domain.Entities.Verspakket", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<int>("AantalPersonen")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime?>("DeletedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("ModifiedAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Naam")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)");
|
||||
|
||||
b.Property<int?>("PrijsInCenten")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<Guid>("SupermarktId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SupermarktId");
|
||||
|
||||
b.ToTable("Verspaketten", t =>
|
||||
{
|
||||
t.HasCheckConstraint("CK_Verspaketten_AantalPersonen", "\"AantalPersonen\" BETWEEN 1 AND 10");
|
||||
|
||||
t.HasCheckConstraint("CK_Verspaketten_PrijsInCenten", "\"PrijsInCenten\" IS NULL OR \"PrijsInCenten\" >= 0");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lutra.Domain.Entities.Beoordeling", b =>
|
||||
{
|
||||
b.HasOne("Lutra.Domain.Entities.Verspakket", null)
|
||||
.WithMany("Beoordelingen")
|
||||
.HasForeignKey("VerspakketId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lutra.Domain.Entities.Verspakket", b =>
|
||||
{
|
||||
b.HasOne("Lutra.Domain.Entities.Supermarkt", "Supermarkt")
|
||||
.WithMany()
|
||||
.HasForeignKey("SupermarktId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Supermarkt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lutra.Domain.Entities.Verspakket", b =>
|
||||
{
|
||||
b.Navigation("Beoordelingen");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Lutra.Infrastructure.Sql.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddPrijsInCentenCheckConstraint : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddCheckConstraint(
|
||||
name: "CK_Verspaketten_PrijsInCenten",
|
||||
table: "Verspaketten",
|
||||
sql: "\"PrijsInCenten\" IS NULL OR \"PrijsInCenten\" >= 0");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropCheckConstraint(
|
||||
name: "CK_Verspaketten_PrijsInCenten",
|
||||
table: "Verspaketten");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ namespace Lutra.Infrastructure.Sql.Migrations
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.5")
|
||||
.HasAnnotation("ProductVersion", "10.0.6")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
@@ -118,7 +118,12 @@ namespace Lutra.Infrastructure.Sql.Migrations
|
||||
|
||||
b.HasIndex("SupermarktId");
|
||||
|
||||
b.ToTable("Verspaketten");
|
||||
b.ToTable("Verspaketten", t =>
|
||||
{
|
||||
t.HasCheckConstraint("CK_Verspaketten_AantalPersonen", "\"AantalPersonen\" BETWEEN 1 AND 10");
|
||||
|
||||
t.HasCheckConstraint("CK_Verspaketten_PrijsInCenten", "\"PrijsInCenten\" IS NULL OR \"PrijsInCenten\" >= 0");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Lutra.Domain.Entities.Beoordeling", b =>
|
||||
|
||||
Reference in New Issue
Block a user