Um neue Projekte hinzuzufügen sollte man update ausführen

This commit is contained in:
Husky
2020-02-26 10:22:29 +01:00
parent 348e6a9f3f
commit 9457784293
7 changed files with 182 additions and 138 deletions

View File

@@ -2,6 +2,7 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Text; using System.Text;
@@ -74,7 +75,19 @@ namespace KanSan.Base
public void Update(TEntity entityToUpdate) public void Update(TEntity entityToUpdate)
{ {
dbSet.Attach(entityToUpdate); dbSet.Attach(entityToUpdate);
context.Entry(entityToUpdate).State = EntityState.Modified; IDatabaseEntry x = (entityToUpdate as IDatabaseEntry);
if(x == null)
return;
if(x.ID.Equals(0))
{
// Scheint ein neuer Eintrag zu sein
context.Entry(entityToUpdate).State = EntityState.Added;
}
else
{
context.Entry(entityToUpdate).State = EntityState.Modified;
}
} }
} }
} }

View File

@@ -18,7 +18,8 @@ namespace KanSan.Base
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
optionsBuilder.UseSqlite("Data Source=kansan.db"); optionsBuilder.UseNpgsql("Host = localhost; Database = kanSan; Username = kansan; Password = kansan");
//optionsBuilder.UseSqlite("Data Source=kansan.db");
} }
} }
} }

View File

@@ -5,36 +5,40 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace KanSan.Base.Migrations namespace KanSan.Base.Migrations
{ {
[DbContext(typeof(KanSanContext))] [DbContext(typeof(KanSanContext))]
[Migration("20200221103518_InitialCommit")] [Migration("20200225192255_InitialCommit")]
partial class InitialCommit partial class InitialCommit
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "3.1.1"); .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
.HasAnnotation("ProductVersion", "3.1.2")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("KanSan.Base.Models.Baustelle", b => modelBuilder.Entity("KanSan.Base.Models.Baustelle", b =>
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("BaustelleNummer") b.Property<string>("BaustelleNummer")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<string>("OrtTeil") b.Property<string>("OrtTeil")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<int?>("ProjektID") b.Property<int?>("ProjektID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.HasKey("ID"); b.HasKey("ID");
@@ -47,13 +51,14 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<string>("Kennzeichen") b.Property<string>("Kennzeichen")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("ID"); b.HasKey("ID");
@@ -64,25 +69,26 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<string>("Nachname") b.Property<string>("Nachname")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("Ort") b.Property<string>("Ort")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("PLZ") b.Property<string>("PLZ")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("Strasse") b.Property<string>("Strasse")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("Vorname") b.Property<string>("Vorname")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("ID"); b.HasKey("ID");
@@ -93,19 +99,20 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Beschreibung") b.Property<string>("Beschreibung")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("Einheit") b.Property<string>("Einheit")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<string>("Positionsnummer") b.Property<string>("Positionsnummer")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("ID"); b.HasKey("ID");
@@ -116,19 +123,20 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<int?>("KundeID") b.Property<int?>("KundeID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<string>("Ort") b.Property<string>("Ort")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("Projektnummer") b.Property<string>("Projektnummer")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("ID"); b.HasKey("ID");
@@ -141,13 +149,14 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<int>("SanierungsTyp") b.Property<int>("SanierungsTyp")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.HasKey("ID"); b.HasKey("ID");
@@ -158,19 +167,20 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<int>("SanierungsTyp") b.Property<int>("SanierungsTyp")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<int?>("SanierungskonzeptID") b.Property<int?>("SanierungskonzeptID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<int?>("SewerID") b.Property<int?>("SewerID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.HasKey("ID"); b.HasKey("ID");
@@ -185,40 +195,41 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int?>("BaustelleID") b.Property<int?>("BaustelleID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<int>("DN") b.Property<int>("DN")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<int>("Material") b.Property<int>("Material")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<string>("ObjektNummer") b.Property<string>("ObjektNummer")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<int?>("PunktObenID") b.Property<int?>("PunktObenID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<int>("PunktTypeOben") b.Property<int>("PunktTypeOben")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<int>("PunktTypeUnten") b.Property<int>("PunktTypeUnten")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<int?>("PunktUntenID") b.Property<int?>("PunktUntenID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<int>("SewerType") b.Property<int>("SewerType")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<string>("StrasseName") b.Property<string>("StrasseName")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("ID"); b.HasKey("ID");
@@ -235,13 +246,14 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<string>("Objektnummer") b.Property<string>("Objektnummer")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("ID"); b.HasKey("ID");
@@ -252,31 +264,32 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<decimal>("Anzahl") b.Property<decimal>("Anzahl")
.HasColumnType("TEXT"); .HasColumnType("numeric");
b.Property<int?>("FahrzeugID") b.Property<int?>("FahrzeugID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<int?>("LeitungsverzeichnisPositionID") b.Property<int?>("LeitungsverzeichnisPositionID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<string>("Mitarbeiter") b.Property<string>("Mitarbeiter")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<decimal>("Position") b.Property<decimal>("Position")
.HasColumnType("TEXT"); .HasColumnType("numeric");
b.Property<int?>("SanierungskonzeptID") b.Property<int?>("SanierungskonzeptID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<DateTime>("ZeitStempel") b.Property<DateTime>("ZeitStempel")
.HasColumnType("TEXT"); .HasColumnType("timestamp without time zone");
b.HasKey("ID"); b.HasKey("ID");

View File

@@ -1,5 +1,6 @@
using System; using System;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace KanSan.Base.Migrations namespace KanSan.Base.Migrations
{ {
@@ -12,7 +13,7 @@ namespace KanSan.Base.Migrations
columns: table => new columns: table => new
{ {
ID = table.Column<int>(nullable: false) ID = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
GuidNr = table.Column<Guid>(nullable: false), GuidNr = table.Column<Guid>(nullable: false),
Kennzeichen = table.Column<string>(nullable: true) Kennzeichen = table.Column<string>(nullable: true)
}, },
@@ -26,7 +27,7 @@ namespace KanSan.Base.Migrations
columns: table => new columns: table => new
{ {
ID = table.Column<int>(nullable: false) ID = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
GuidNr = table.Column<Guid>(nullable: false), GuidNr = table.Column<Guid>(nullable: false),
Vorname = table.Column<string>(nullable: true), Vorname = table.Column<string>(nullable: true),
Nachname = table.Column<string>(nullable: true), Nachname = table.Column<string>(nullable: true),
@@ -44,7 +45,7 @@ namespace KanSan.Base.Migrations
columns: table => new columns: table => new
{ {
ID = table.Column<int>(nullable: false) ID = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
GuidNr = table.Column<Guid>(nullable: false), GuidNr = table.Column<Guid>(nullable: false),
Positionsnummer = table.Column<string>(nullable: true), Positionsnummer = table.Column<string>(nullable: true),
Beschreibung = table.Column<string>(nullable: true), Beschreibung = table.Column<string>(nullable: true),
@@ -60,7 +61,7 @@ namespace KanSan.Base.Migrations
columns: table => new columns: table => new
{ {
ID = table.Column<int>(nullable: false) ID = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
GuidNr = table.Column<Guid>(nullable: false), GuidNr = table.Column<Guid>(nullable: false),
SanierungsTyp = table.Column<int>(nullable: false) SanierungsTyp = table.Column<int>(nullable: false)
}, },
@@ -74,7 +75,7 @@ namespace KanSan.Base.Migrations
columns: table => new columns: table => new
{ {
ID = table.Column<int>(nullable: false) ID = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
GuidNr = table.Column<Guid>(nullable: false), GuidNr = table.Column<Guid>(nullable: false),
Objektnummer = table.Column<string>(nullable: true) Objektnummer = table.Column<string>(nullable: true)
}, },
@@ -88,7 +89,7 @@ namespace KanSan.Base.Migrations
columns: table => new columns: table => new
{ {
ID = table.Column<int>(nullable: false) ID = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
GuidNr = table.Column<Guid>(nullable: false), GuidNr = table.Column<Guid>(nullable: false),
KundeID = table.Column<int>(nullable: true), KundeID = table.Column<int>(nullable: true),
Ort = table.Column<string>(nullable: true), Ort = table.Column<string>(nullable: true),
@@ -110,7 +111,7 @@ namespace KanSan.Base.Migrations
columns: table => new columns: table => new
{ {
ID = table.Column<int>(nullable: false) ID = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
GuidNr = table.Column<Guid>(nullable: false), GuidNr = table.Column<Guid>(nullable: false),
SanierungskonzeptID = table.Column<int>(nullable: true), SanierungskonzeptID = table.Column<int>(nullable: true),
FahrzeugID = table.Column<int>(nullable: true), FahrzeugID = table.Column<int>(nullable: true),
@@ -130,7 +131,7 @@ namespace KanSan.Base.Migrations
principalColumn: "ID", principalColumn: "ID",
onDelete: ReferentialAction.Restrict); onDelete: ReferentialAction.Restrict);
table.ForeignKey( table.ForeignKey(
name: "FK_Taetigkeiten_LeitungsverzeichnisPositionen_LeitungsverzeichnisPositionID", name: "FK_Taetigkeiten_LeitungsverzeichnisPositionen_Leitungsverzeich~",
column: x => x.LeitungsverzeichnisPositionID, column: x => x.LeitungsverzeichnisPositionID,
principalTable: "LeitungsverzeichnisPositionen", principalTable: "LeitungsverzeichnisPositionen",
principalColumn: "ID", principalColumn: "ID",
@@ -148,7 +149,7 @@ namespace KanSan.Base.Migrations
columns: table => new columns: table => new
{ {
ID = table.Column<int>(nullable: false) ID = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
GuidNr = table.Column<Guid>(nullable: false), GuidNr = table.Column<Guid>(nullable: false),
ProjektID = table.Column<int>(nullable: true), ProjektID = table.Column<int>(nullable: true),
OrtTeil = table.Column<string>(nullable: true), OrtTeil = table.Column<string>(nullable: true),
@@ -170,7 +171,7 @@ namespace KanSan.Base.Migrations
columns: table => new columns: table => new
{ {
ID = table.Column<int>(nullable: false) ID = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
GuidNr = table.Column<Guid>(nullable: false), GuidNr = table.Column<Guid>(nullable: false),
BaustelleID = table.Column<int>(nullable: true), BaustelleID = table.Column<int>(nullable: true),
StrasseName = table.Column<string>(nullable: true), StrasseName = table.Column<string>(nullable: true),
@@ -211,7 +212,7 @@ namespace KanSan.Base.Migrations
columns: table => new columns: table => new
{ {
ID = table.Column<int>(nullable: false) ID = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true), .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
GuidNr = table.Column<Guid>(nullable: false), GuidNr = table.Column<Guid>(nullable: false),
SewerID = table.Column<int>(nullable: true), SewerID = table.Column<int>(nullable: true),
SanierungsTyp = table.Column<int>(nullable: false), SanierungsTyp = table.Column<int>(nullable: false),

View File

@@ -4,6 +4,7 @@ using KanSan.Base;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace KanSan.Base.Migrations namespace KanSan.Base.Migrations
{ {
@@ -14,25 +15,28 @@ namespace KanSan.Base.Migrations
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "3.1.1"); .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
.HasAnnotation("ProductVersion", "3.1.2")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("KanSan.Base.Models.Baustelle", b => modelBuilder.Entity("KanSan.Base.Models.Baustelle", b =>
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("BaustelleNummer") b.Property<string>("BaustelleNummer")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<string>("OrtTeil") b.Property<string>("OrtTeil")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<int?>("ProjektID") b.Property<int?>("ProjektID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.HasKey("ID"); b.HasKey("ID");
@@ -45,13 +49,14 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<string>("Kennzeichen") b.Property<string>("Kennzeichen")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("ID"); b.HasKey("ID");
@@ -62,25 +67,26 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<string>("Nachname") b.Property<string>("Nachname")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("Ort") b.Property<string>("Ort")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("PLZ") b.Property<string>("PLZ")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("Strasse") b.Property<string>("Strasse")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("Vorname") b.Property<string>("Vorname")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("ID"); b.HasKey("ID");
@@ -91,19 +97,20 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Beschreibung") b.Property<string>("Beschreibung")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("Einheit") b.Property<string>("Einheit")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<string>("Positionsnummer") b.Property<string>("Positionsnummer")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("ID"); b.HasKey("ID");
@@ -114,19 +121,20 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<int?>("KundeID") b.Property<int?>("KundeID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<string>("Ort") b.Property<string>("Ort")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<string>("Projektnummer") b.Property<string>("Projektnummer")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("ID"); b.HasKey("ID");
@@ -139,13 +147,14 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<int>("SanierungsTyp") b.Property<int>("SanierungsTyp")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.HasKey("ID"); b.HasKey("ID");
@@ -156,19 +165,20 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<int>("SanierungsTyp") b.Property<int>("SanierungsTyp")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<int?>("SanierungskonzeptID") b.Property<int?>("SanierungskonzeptID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<int?>("SewerID") b.Property<int?>("SewerID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.HasKey("ID"); b.HasKey("ID");
@@ -183,40 +193,41 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int?>("BaustelleID") b.Property<int?>("BaustelleID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<int>("DN") b.Property<int>("DN")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<int>("Material") b.Property<int>("Material")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<string>("ObjektNummer") b.Property<string>("ObjektNummer")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<int?>("PunktObenID") b.Property<int?>("PunktObenID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<int>("PunktTypeOben") b.Property<int>("PunktTypeOben")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<int>("PunktTypeUnten") b.Property<int>("PunktTypeUnten")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<int?>("PunktUntenID") b.Property<int?>("PunktUntenID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<int>("SewerType") b.Property<int>("SewerType")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<string>("StrasseName") b.Property<string>("StrasseName")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("ID"); b.HasKey("ID");
@@ -233,13 +244,14 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<string>("Objektnummer") b.Property<string>("Objektnummer")
.HasColumnType("TEXT"); .HasColumnType("text");
b.HasKey("ID"); b.HasKey("ID");
@@ -250,31 +262,32 @@ namespace KanSan.Base.Migrations
{ {
b.Property<int>("ID") b.Property<int>("ID")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<decimal>("Anzahl") b.Property<decimal>("Anzahl")
.HasColumnType("TEXT"); .HasColumnType("numeric");
b.Property<int?>("FahrzeugID") b.Property<int?>("FahrzeugID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<Guid>("GuidNr") b.Property<Guid>("GuidNr")
.HasColumnType("TEXT"); .HasColumnType("uuid");
b.Property<int?>("LeitungsverzeichnisPositionID") b.Property<int?>("LeitungsverzeichnisPositionID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<string>("Mitarbeiter") b.Property<string>("Mitarbeiter")
.HasColumnType("TEXT"); .HasColumnType("text");
b.Property<decimal>("Position") b.Property<decimal>("Position")
.HasColumnType("TEXT"); .HasColumnType("numeric");
b.Property<int?>("SanierungskonzeptID") b.Property<int?>("SanierungskonzeptID")
.HasColumnType("INTEGER"); .HasColumnType("integer");
b.Property<DateTime>("ZeitStempel") b.Property<DateTime>("ZeitStempel")
.HasColumnType("TEXT"); .HasColumnType("timestamp without time zone");
b.HasKey("ID"); b.HasKey("ID");

View File

@@ -31,15 +31,17 @@ namespace KanSan.ViewModel
public Kunde NeueKunde() public Kunde NeueKunde()
{ {
Kunde result = new Kunde(); Kunde result = new Kunde();
//result.ID = 1;
result.GuidNr = Guid.NewGuid(); result.GuidNr = Guid.NewGuid();
unitOfWork.KundenRepository.Insert(result); unitOfWork.KundenRepository.Insert(result);
unitOfWork.Commit(); unitOfWork.Commit();
return result;
IEnumerable<Kunde> kunden = unitOfWork.KundenRepository.Get(d => d.GuidNr.Equals(result.GuidNr)); //IEnumerable<Kunde> kunden = unitOfWork.KundenRepository.Get(d => d.GuidNr.Equals(result.GuidNr));
if (kunden.Count() < 1) //if (kunden.Count() < 1)
throw new Exception("Kunde konnte nicht gefunden werden"); // throw new Exception("Kunde konnte nicht gefunden werden");
return kunden.First(); //return kunden.First();
} }
} }
} }

View File

@@ -15,9 +15,9 @@ namespace KanSan.ViewModel
public ProjektListViewModel(Kunde client) public ProjektListViewModel(Kunde client)
{ {
List<Kunde> clients = unitOfWork.KundenRepository.Get(x => x.GuidNr.Equals(client.GuidNr)).ToList(); //List<Kunde> clients = unitOfWork.KundenRepository.Get(x => x.GuidNr.Equals(client.GuidNr)).ToList();
this.selectedKunde = clients.First(); //this.selectedKunde = clients.First();
//this.selectedKunde = selectedKunde; this.selectedKunde = client;
@@ -38,7 +38,8 @@ namespace KanSan.ViewModel
Kunde = selectedKunde Kunde = selectedKunde
}; };
unitOfWork.ProjekteRepository.Insert(newProjekt); unitOfWork.ProjekteRepository.Update(newProjekt);
//unitOfWork.ProjekteRepository.Insert(newProjekt);
unitOfWork.Commit(); unitOfWork.Commit();
List<Projekt> res = unitOfWork.ProjekteRepository.Get(x => x.GuidNr.Equals(guid)).ToList(); List<Projekt> res = unitOfWork.ProjekteRepository.Get(x => x.GuidNr.Equals(guid)).ToList();