Projekte können erstellt und geladen werden

This commit is contained in:
2023-03-30 20:56:21 +02:00
parent e5214e44c3
commit 70bba66df3
32 changed files with 1050 additions and 93 deletions

View File

@@ -0,0 +1,220 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using SewerStammGen.EntityFramework;
#nullable disable
namespace SewerStammGen.EntityFramework.Migrations
{
[DbContext(typeof(SewerStammGenDbContext))]
[Migration("20230330100444_AddedNullValue")]
partial class AddedNullValue
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Shared.Domain.Auftraggeber", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Ansprechpartner")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Ort")
.HasColumnType("text");
b.Property<string>("Postleitzahl")
.HasColumnType("text");
b.Property<string>("Strasse")
.HasColumnType("text");
b.Property<string>("Telefonnummer")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Auftraggebers");
});
modelBuilder.Entity("Shared.Domain.Kanal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("DN")
.HasColumnType("integer");
b.Property<int?>("EndSchachtId")
.HasColumnType("integer");
b.Property<int>("Entwaesserung")
.HasColumnType("integer");
b.Property<decimal>("Haltungslaenge")
.HasColumnType("numeric");
b.Property<string>("Material")
.HasColumnType("text");
b.Property<string>("Objektbezeichnung")
.HasColumnType("text");
b.Property<int?>("ProjektId")
.HasColumnType("integer");
b.Property<int?>("StartSchachtId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("EndSchachtId");
b.HasIndex("ProjektId");
b.HasIndex("StartSchachtId");
b.ToTable("Kanaele");
});
modelBuilder.Entity("Shared.Domain.Projekt", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("AuftraggeberId")
.HasColumnType("integer");
b.Property<string>("Erstelldatum")
.HasColumnType("text");
b.Property<int>("ExportType")
.HasColumnType("integer");
b.Property<int>("Kodierungssystem")
.HasColumnType("integer");
b.Property<string>("Ort")
.HasColumnType("text");
b.Property<string>("Projektname")
.HasColumnType("text");
b.Property<string>("Strasse")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("AuftraggeberId");
b.ToTable("Projekte");
});
modelBuilder.Entity("Shared.Domain.Schacht", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("DeckelHoehe")
.HasColumnType("decimal(18,4)");
b.Property<int>("Entwaesserung")
.HasColumnType("integer");
b.Property<decimal>("HochWert")
.HasColumnType("decimal(18,4)");
b.Property<string>("Objektbezeichnung")
.HasColumnType("text");
b.Property<int?>("ProjektId")
.HasColumnType("integer");
b.Property<decimal>("RechtsWert")
.HasColumnType("decimal(18,4)");
b.Property<decimal>("SohlHoehe")
.HasColumnType("decimal(18,4)");
b.HasKey("Id");
b.HasIndex("ProjektId");
b.ToTable("Schaechte");
});
modelBuilder.Entity("Shared.Domain.Kanal", b =>
{
b.HasOne("Shared.Domain.Schacht", "EndSchacht")
.WithMany()
.HasForeignKey("EndSchachtId");
b.HasOne("Shared.Domain.Projekt", null)
.WithMany("Kanaele")
.HasForeignKey("ProjektId");
b.HasOne("Shared.Domain.Schacht", "StartSchacht")
.WithMany()
.HasForeignKey("StartSchachtId");
b.Navigation("EndSchacht");
b.Navigation("StartSchacht");
});
modelBuilder.Entity("Shared.Domain.Projekt", b =>
{
b.HasOne("Shared.Domain.Auftraggeber", "Auftraggeber")
.WithMany()
.HasForeignKey("AuftraggeberId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Auftraggeber");
});
modelBuilder.Entity("Shared.Domain.Schacht", b =>
{
b.HasOne("Shared.Domain.Projekt", null)
.WithMany("Schaechte")
.HasForeignKey("ProjektId");
});
modelBuilder.Entity("Shared.Domain.Projekt", b =>
{
b.Navigation("Kanaele");
b.Navigation("Schaechte");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,252 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SewerStammGen.EntityFramework.Migrations
{
/// <inheritdoc />
public partial class AddedNullValue : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Objektbezeichnung",
table: "Schaechte",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Strasse",
table: "Projekte",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Projektname",
table: "Projekte",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Ort",
table: "Projekte",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Erstelldatum",
table: "Projekte",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Objektbezeichnung",
table: "Kanaele",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Material",
table: "Kanaele",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Telefonnummer",
table: "Auftraggebers",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Strasse",
table: "Auftraggebers",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Postleitzahl",
table: "Auftraggebers",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Ort",
table: "Auftraggebers",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "Auftraggebers",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
migrationBuilder.AlterColumn<string>(
name: "Ansprechpartner",
table: "Auftraggebers",
type: "text",
nullable: true,
oldClrType: typeof(string),
oldType: "text");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Objektbezeichnung",
table: "Schaechte",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Strasse",
table: "Projekte",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Projektname",
table: "Projekte",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Ort",
table: "Projekte",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Erstelldatum",
table: "Projekte",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Objektbezeichnung",
table: "Kanaele",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Material",
table: "Kanaele",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Telefonnummer",
table: "Auftraggebers",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Strasse",
table: "Auftraggebers",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Postleitzahl",
table: "Auftraggebers",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Ort",
table: "Auftraggebers",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Name",
table: "Auftraggebers",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "Ansprechpartner",
table: "Auftraggebers",
type: "text",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldNullable: true);
}
}
}

View File

@@ -31,27 +31,21 @@ namespace SewerStammGen.EntityFramework.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Ansprechpartner")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Ort")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Postleitzahl")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Strasse")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Telefonnummer")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@@ -80,11 +74,9 @@ namespace SewerStammGen.EntityFramework.Migrations
.HasColumnType("numeric");
b.Property<string>("Material")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Objektbezeichnung")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("ProjektId")
@@ -116,7 +108,6 @@ namespace SewerStammGen.EntityFramework.Migrations
.HasColumnType("integer");
b.Property<string>("Erstelldatum")
.IsRequired()
.HasColumnType("text");
b.Property<int>("ExportType")
@@ -126,15 +117,12 @@ namespace SewerStammGen.EntityFramework.Migrations
.HasColumnType("integer");
b.Property<string>("Ort")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Projektname")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Strasse")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
@@ -162,7 +150,6 @@ namespace SewerStammGen.EntityFramework.Migrations
.HasColumnType("decimal(18,4)");
b.Property<string>("Objektbezeichnung")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("ProjektId")

View File

@@ -36,7 +36,8 @@ namespace SewerStammGen.EntityFramework.Services.Common
public async Task<bool> Delete(int id)
{
using SewerStammGenDbContext context = _contextFactory.CreateDbContext();
T entity = await context.Set<T>().FirstOrDefaultAsync((e) => e.Id == id);
T? entity = await context.Set<T>().FirstOrDefaultAsync((e) => e.Id == id);
if (entity == null) return false;
context.Set<T>().Remove(entity);
await context.SaveChangesAsync();
return true;