Compare commits
7 Commits
haltung_ed
...
remove_ef
| Author | SHA1 | Date | |
|---|---|---|---|
| 47aba01cb4 | |||
| 047e036442 | |||
| 1d649d14cb | |||
| 6878284b61 | |||
| 7a036b3404 | |||
| b100eca490 | |||
| 1c3e3c876b |
20
SQL/Auftraggebers.sql
Normal file
20
SQL/Auftraggebers.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- Table: public.Auftraggebers
|
||||
|
||||
-- DROP TABLE IF EXISTS public."Auftraggebers";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public."Auftraggebers"
|
||||
(
|
||||
"Id" integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
|
||||
"Name" text COLLATE pg_catalog."default",
|
||||
"Strasse" text COLLATE pg_catalog."default",
|
||||
"Ort" text COLLATE pg_catalog."default",
|
||||
"Postleitzahl" text COLLATE pg_catalog."default",
|
||||
"Ansprechpartner" text COLLATE pg_catalog."default",
|
||||
"Telefonnummer" text COLLATE pg_catalog."default",
|
||||
CONSTRAINT "PK_Auftraggebers" PRIMARY KEY ("Id")
|
||||
)
|
||||
|
||||
TABLESPACE pg_default;
|
||||
|
||||
ALTER TABLE IF EXISTS public."Auftraggebers"
|
||||
OWNER to "SewerGen";
|
||||
58
SQL/Kanaele.sql
Normal file
58
SQL/Kanaele.sql
Normal file
@@ -0,0 +1,58 @@
|
||||
-- Table: public.Kanaele
|
||||
|
||||
-- DROP TABLE IF EXISTS public."Kanaele";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public."Kanaele"
|
||||
(
|
||||
"Id" integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
|
||||
"Objektbezeichnung" text COLLATE pg_catalog."default",
|
||||
"StartSchachtId" integer,
|
||||
"EndSchachtId" integer,
|
||||
"DN" integer NOT NULL,
|
||||
"Material" text COLLATE pg_catalog."default",
|
||||
"Haltungslaenge" numeric NOT NULL,
|
||||
"Entwaesserung" integer NOT NULL,
|
||||
"ProjektId" integer,
|
||||
CONSTRAINT "PK_Kanaele" PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "FK_Kanaele_Projekte_ProjektId" FOREIGN KEY ("ProjektId")
|
||||
REFERENCES public."Projekte" ("Id") MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION,
|
||||
CONSTRAINT "FK_Kanaele_Schaechte_EndSchachtId" FOREIGN KEY ("EndSchachtId")
|
||||
REFERENCES public."Schaechte" ("Id") MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION,
|
||||
CONSTRAINT "FK_Kanaele_Schaechte_StartSchachtId" FOREIGN KEY ("StartSchachtId")
|
||||
REFERENCES public."Schaechte" ("Id") MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION
|
||||
)
|
||||
|
||||
TABLESPACE pg_default;
|
||||
|
||||
ALTER TABLE IF EXISTS public."Kanaele"
|
||||
OWNER to "SewerGen";
|
||||
-- Index: IX_Kanaele_EndSchachtId
|
||||
|
||||
-- DROP INDEX IF EXISTS public."IX_Kanaele_EndSchachtId";
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "IX_Kanaele_EndSchachtId"
|
||||
ON public."Kanaele" USING btree
|
||||
("EndSchachtId" ASC NULLS LAST)
|
||||
TABLESPACE pg_default;
|
||||
-- Index: IX_Kanaele_ProjektId
|
||||
|
||||
-- DROP INDEX IF EXISTS public."IX_Kanaele_ProjektId";
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "IX_Kanaele_ProjektId"
|
||||
ON public."Kanaele" USING btree
|
||||
("ProjektId" ASC NULLS LAST)
|
||||
TABLESPACE pg_default;
|
||||
-- Index: IX_Kanaele_StartSchachtId
|
||||
|
||||
-- DROP INDEX IF EXISTS public."IX_Kanaele_StartSchachtId";
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "IX_Kanaele_StartSchachtId"
|
||||
ON public."Kanaele" USING btree
|
||||
("StartSchachtId" ASC NULLS LAST)
|
||||
TABLESPACE pg_default;
|
||||
33
SQL/Projekte.sql
Normal file
33
SQL/Projekte.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
-- Table: public.Projekte
|
||||
|
||||
-- DROP TABLE IF EXISTS public."Projekte";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public."Projekte"
|
||||
(
|
||||
"Id" integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
|
||||
"Projektname" text COLLATE pg_catalog."default",
|
||||
"Erstelldatum" text COLLATE pg_catalog."default",
|
||||
"Strasse" text COLLATE pg_catalog."default",
|
||||
"Ort" text COLLATE pg_catalog."default",
|
||||
"ExportType" integer NOT NULL,
|
||||
"Kodierungssystem" integer NOT NULL,
|
||||
"AuftraggeberId" integer NOT NULL DEFAULT 0,
|
||||
CONSTRAINT "PK_Projekte" PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "FK_Projekte_Auftraggebers_AuftraggeberId" FOREIGN KEY ("AuftraggeberId")
|
||||
REFERENCES public."Auftraggebers" ("Id") MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE CASCADE
|
||||
)
|
||||
|
||||
TABLESPACE pg_default;
|
||||
|
||||
ALTER TABLE IF EXISTS public."Projekte"
|
||||
OWNER to "SewerGen";
|
||||
-- Index: IX_Projekte_AuftraggeberId
|
||||
|
||||
-- DROP INDEX IF EXISTS public."IX_Projekte_AuftraggeberId";
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "IX_Projekte_AuftraggeberId"
|
||||
ON public."Projekte" USING btree
|
||||
("AuftraggeberId" ASC NULLS LAST)
|
||||
TABLESPACE pg_default;
|
||||
33
SQL/Schaechte.sql
Normal file
33
SQL/Schaechte.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
-- Table: public.Schaechte
|
||||
|
||||
-- DROP TABLE IF EXISTS public."Schaechte";
|
||||
|
||||
CREATE TABLE IF NOT EXISTS public."Schaechte"
|
||||
(
|
||||
"Id" integer NOT NULL GENERATED BY DEFAULT AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 2147483647 CACHE 1 ),
|
||||
"Objektbezeichnung" text COLLATE pg_catalog."default",
|
||||
"RechtsWert" numeric(18,4) NOT NULL,
|
||||
"HochWert" numeric(18,4) NOT NULL,
|
||||
"SohlHoehe" numeric(18,4) NOT NULL,
|
||||
"DeckelHoehe" numeric(18,4) NOT NULL,
|
||||
"Entwaesserung" integer NOT NULL,
|
||||
"ProjektId" integer,
|
||||
CONSTRAINT "PK_Schaechte" PRIMARY KEY ("Id"),
|
||||
CONSTRAINT "FK_Schaechte_Projekte_ProjektId" FOREIGN KEY ("ProjektId")
|
||||
REFERENCES public."Projekte" ("Id") MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION
|
||||
)
|
||||
|
||||
TABLESPACE pg_default;
|
||||
|
||||
ALTER TABLE IF EXISTS public."Schaechte"
|
||||
OWNER to "SewerGen";
|
||||
-- Index: IX_Schaechte_ProjektId
|
||||
|
||||
-- DROP INDEX IF EXISTS public."IX_Schaechte_ProjektId";
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "IX_Schaechte_ProjektId"
|
||||
ON public."Schaechte" USING btree
|
||||
("ProjektId" ASC NULLS LAST)
|
||||
TABLESPACE pg_default;
|
||||
10
SewerStammGen.Console/Program.cs
Normal file
10
SewerStammGen.Console/Program.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace SewerStammGen.Console
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Hello, World!");
|
||||
}
|
||||
}
|
||||
}
|
||||
15
SewerStammGen.Console/SewerStammGen.Console.csproj
Normal file
15
SewerStammGen.Console/SewerStammGen.Console.csproj
Normal file
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SewerStammGen.DAL\SewerStammGen.DAL.csproj" />
|
||||
<ProjectReference Include="..\Shared\SewerStammGen.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
43
SewerStammGen.ConsoleApp/Program.cs
Normal file
43
SewerStammGen.ConsoleApp/Program.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using SewerStammGen.DAL.Services;
|
||||
using SewerStammGen.DAL.Services.PostgresqlData;
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.Shared.Enum;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace SewerStammGen.ConsoleApp
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
IProjektDataService projektService = new ProjektDataService();
|
||||
|
||||
Projekt neuesProjekt = new Projekt()
|
||||
{
|
||||
Erstelldatum = "test",
|
||||
Projektname = "test",
|
||||
Kodierungssystem = EKodierungssystem.EN13508_2_2011,
|
||||
ExportType = EExportType.XML2006,
|
||||
Ort = "test",
|
||||
Strasse = "test",
|
||||
};
|
||||
|
||||
//test(neuesProjekt, projektService);
|
||||
readtest(projektService);
|
||||
Console.WriteLine("Hello, World!");
|
||||
}
|
||||
|
||||
private static async void readtest(IProjektDataService projektService)
|
||||
{
|
||||
var m = await projektService.GetAll();
|
||||
Debugger.Break();
|
||||
}
|
||||
|
||||
private static async void test(Projekt neuesProjekt, IProjektDataService projektService)
|
||||
{
|
||||
var m = await projektService.Create(neuesProjekt);
|
||||
Console.WriteLine(m.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
16
SewerStammGen.ConsoleApp/SewerStammGen.ConsoleApp.csproj
Normal file
16
SewerStammGen.ConsoleApp/SewerStammGen.ConsoleApp.csproj
Normal file
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SewerStammGen.DAL\SewerStammGen.DAL.csproj" />
|
||||
<ProjectReference Include="..\SewerStammGen.Shared\SewerStammGen.Shared.csproj" />
|
||||
<ProjectReference Include="..\Shared\SewerStammGen.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,83 @@
|
||||
using Npgsql;
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
{
|
||||
public class AuftraggeberDataService : PostgresqlDataService, IAuftraggeberDataService
|
||||
{
|
||||
public AuftraggeberDataService(string connectionstring) : base(connectionstring,"Auftraggebers") { }
|
||||
|
||||
public async Task<Auftraggeber> Create(Auftraggeber entity)
|
||||
{
|
||||
string command = "INSERT INTO "+tableName+" (\"Name\", \"Strasse\", \"Ort\", \"Postleitzahl\", \"Ansprechpartner\", \"Telefonnummer\") " +
|
||||
"VALUES(@1,@2,@3,@4,@5,@6) RETURNING \"Id\"";
|
||||
|
||||
await using (var cmd = new NpgsqlCommand(command, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("1", entity.Name);
|
||||
cmd.Parameters.AddWithValue("2", entity.Strasse);
|
||||
cmd.Parameters.AddWithValue("3", entity.Ort);
|
||||
cmd.Parameters.AddWithValue("4", entity.Postleitzahl);
|
||||
cmd.Parameters.AddWithValue("5", entity.Ansprechpartner);
|
||||
cmd.Parameters.AddWithValue("6", entity.Telefonnummer);
|
||||
|
||||
using var reader = await cmd.ExecuteReaderAsync();
|
||||
reader.Read();
|
||||
entity.Id = reader.GetInt32(0);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<Auftraggeber> Get(int id)
|
||||
{
|
||||
Auftraggeber result = new Auftraggeber();
|
||||
using (var cmd = new NpgsqlCommand($"SELECT * FROM "+tableName+" WHERE \"Id\" = @1", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("1", id);
|
||||
using var reader = await cmd.ExecuteReaderAsync();
|
||||
reader.Read();
|
||||
result = parseAuftraggeber(reader);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Auftraggeber parseAuftraggeber(NpgsqlDataReader reader)
|
||||
{
|
||||
return new Auftraggeber()
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
Name = reader.IsDBNull(1) ? "" : reader.GetString(1),
|
||||
Strasse = reader.IsDBNull(2) ? "" : reader.GetString(2),
|
||||
Ort = reader.IsDBNull(3) ? "" : reader.GetString(3),
|
||||
Postleitzahl = reader.IsDBNull(4) ? "" : reader.GetString(4),
|
||||
Ansprechpartner = reader.IsDBNull(5) ? "" : reader.GetString(5),
|
||||
Telefonnummer = reader.IsDBNull(6) ? "" : reader.GetString(6)
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Auftraggeber>> GetAll()
|
||||
{
|
||||
List<Auftraggeber> result = new List<Auftraggeber>();
|
||||
using (var cmd = new NpgsqlCommand($"SELECT * FROM "+tableName, conn))
|
||||
using (var reader = await cmd.ExecuteReaderAsync())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Add(parseAuftraggeber(reader));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<Auftraggeber> Update(Auftraggeber entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using Npgsql;
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
{
|
||||
public class HaltungDataService : PostgresqlDataService, IHaltungDataService
|
||||
{
|
||||
public HaltungDataService(string connectionstring) : base(connectionstring, "Kanaele")
|
||||
{
|
||||
}
|
||||
|
||||
public Task<Kanal> Create(Kanal entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<Kanal> Get(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<IEnumerable<Kanal>> GetAll()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Kanal>> GetAllByProjekt(int projektID)
|
||||
{
|
||||
List<Kanal> result = new List<Kanal>();
|
||||
ISchachtDataService schachtDataService = new SchachtDataService(connString);
|
||||
IEnumerable<Schacht> schaechte = await schachtDataService.GetAllByProjekt(projektID);
|
||||
|
||||
string command = "SELECT * FROM " + tableName + " WHERE \"ProjektId\" = @1";
|
||||
using (var cmd = new NpgsqlCommand(command, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("1", projektID);
|
||||
using (var reader = await cmd.ExecuteReaderAsync())
|
||||
{
|
||||
while(reader.Read())
|
||||
{
|
||||
Kanal adding = parseHaltung(reader);
|
||||
|
||||
adding.StartSchacht = schaechte.Where(x => x.Id == reader.GetInt32(2)).Last();
|
||||
adding.EndSchacht = schaechte.Where(x => x.Id == reader.GetInt32(3)).Last();
|
||||
result.Add(adding);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
private Kanal parseHaltung(NpgsqlDataReader reader)
|
||||
{
|
||||
return new Kanal()
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
Objektbezeichnung = reader.GetString(1),
|
||||
//StartSchacht = reader.GetInt32(2),
|
||||
//EndSchacht = reader.GetInt32(3),
|
||||
DN = reader.GetInt32(4),
|
||||
Material = reader.GetString(5),
|
||||
Haltungslaenge = reader.GetDecimal(6),
|
||||
Entwaesserung = (EEntwaeserung)reader.GetInt32(7),
|
||||
Projekt = new Projekt() { Id = reader.GetInt32(8) }
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Kanal>> GetAllByProjekt(Projekt projekt)
|
||||
{
|
||||
return await GetAllByProjekt(projekt.Id);
|
||||
}
|
||||
|
||||
public Task<Kanal> Update(Kanal entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using Npgsql;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
{
|
||||
public class PostgresqlDataService : IDisposable
|
||||
{
|
||||
protected readonly string connString; // = "Host = localhost; Database = SewerGen; Username = SewerGen; Password = SewerGen";
|
||||
NpgsqlDataSource dataSource;
|
||||
protected NpgsqlConnection? conn = null;
|
||||
protected string tableName = "";
|
||||
|
||||
public PostgresqlDataService(string connectionstring, string tableName)
|
||||
{
|
||||
this.connString = connectionstring;
|
||||
var dataSourceBuilder = new NpgsqlDataSourceBuilder(connString);
|
||||
dataSource = dataSourceBuilder.Build();
|
||||
|
||||
conn = dataSource.OpenConnection();
|
||||
this.tableName = string.Format("public.\"{0}\"", tableName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public virtual async Task<bool> Delete(int id)
|
||||
{
|
||||
string command = $"DELETE " + tableName + " WHERE \"Id\" = @1";
|
||||
await using (var cmd = new NpgsqlCommand(command, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("1", id);
|
||||
int res = await cmd.ExecuteNonQueryAsync();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (conn != null && conn.State == System.Data.ConnectionState.Open)
|
||||
{
|
||||
conn.Close();
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
118
SewerStammGen.DAL/Services/PostgresqlData/ProjektDataService.cs
Normal file
118
SewerStammGen.DAL/Services/PostgresqlData/ProjektDataService.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Npgsql;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.Shared.Enum;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
{
|
||||
public class ProjektDataService : PostgresqlDataService, IProjektDataService
|
||||
{
|
||||
public ProjektDataService(string connectionstring) : base(connectionstring,"Projekte")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public async Task<Projekt> Create(Projekt entity)
|
||||
{
|
||||
string command = "INSERT INTO "+tableName+" (\"Projektname\", \"Erstelldatum\", \"Strasse\", \"Ort\", \"ExportType\", \"Kodierungssystem\",\"AuftraggeberId\") " +
|
||||
"VALUES(@1,@2,@3,@4,@5,@6,@7) RETURNING \"Id\"";
|
||||
|
||||
if (entity.Auftraggeber.Id == 0)
|
||||
{
|
||||
IAuftraggeberDataService auftraggeberDataService = new AuftraggeberDataService(connString);
|
||||
var s = await auftraggeberDataService.GetAll();
|
||||
entity.Auftraggeber = s.ToList().Last();
|
||||
}
|
||||
|
||||
await using (var cmd = new NpgsqlCommand(command, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("1", entity.Projektname);
|
||||
cmd.Parameters.AddWithValue("2", entity.Erstelldatum);
|
||||
cmd.Parameters.AddWithValue("3", entity.Strasse);
|
||||
cmd.Parameters.AddWithValue("4", entity.Ort);
|
||||
cmd.Parameters.AddWithValue("5", (int)entity.ExportType);
|
||||
cmd.Parameters.AddWithValue("6", (int)entity.Kodierungssystem);
|
||||
cmd.Parameters.AddWithValue("7", entity.Auftraggeber.Id);
|
||||
using var reader = await cmd.ExecuteReaderAsync();
|
||||
reader.Read();
|
||||
entity.Id = reader.GetInt32(0);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
public async Task<Projekt> Get(int id)
|
||||
{
|
||||
Projekt result = new Projekt();
|
||||
IAuftraggeberDataService auftraggeberDataService = new AuftraggeberDataService(connString);
|
||||
using (var cmd = new NpgsqlCommand($"SELECT * FROM "+tableName+" WHERE \"Id\" = @1", conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("1", id);
|
||||
using var reader = await cmd.ExecuteReaderAsync();
|
||||
reader.Read();
|
||||
result = parseProjekt(reader);
|
||||
result.Auftraggeber = await auftraggeberDataService.Get(reader.GetInt32(7));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Projekt parseProjekt(NpgsqlDataReader reader)
|
||||
{
|
||||
return new Projekt()
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
Projektname = reader.IsDBNull(1) ? "" : reader.GetString(1),
|
||||
Erstelldatum = reader.IsDBNull(2) ? "" : reader.GetString(2),
|
||||
Strasse = reader.IsDBNull(3) ? "" : reader.GetString(3),
|
||||
Ort = reader.IsDBNull(4) ? "" : reader.GetString(4),
|
||||
ExportType = reader.IsDBNull(5) ? EExportType.XML2013 : (EExportType)reader.GetInt32(5),
|
||||
Kodierungssystem = reader.IsDBNull(6) ? EKodierungssystem.EN13508_2_2011_DWA_M_192_2 : (EKodierungssystem)reader.GetInt32(6)
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Projekt>> GetAll()
|
||||
{
|
||||
IAuftraggeberDataService auftraggeberDataService = new AuftraggeberDataService(connString);
|
||||
|
||||
IEnumerable<Auftraggeber> auftraggebers = await auftraggeberDataService.GetAll();
|
||||
|
||||
List<Projekt> result = new List<Projekt>();
|
||||
using (var cmd = new NpgsqlCommand($"SELECT * FROM " + tableName, conn))
|
||||
using (var reader = await cmd.ExecuteReaderAsync())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
Projekt projekt = parseProjekt(reader);
|
||||
projekt.Auftraggeber = auftraggebers.Where(x => x.Id == reader.GetInt32(7)).ToList().Last();
|
||||
result.Add(projekt);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<Projekt> Update(Projekt entity)
|
||||
{
|
||||
string command = "UPDATE "+tableName+" SET \"Projektname\"=@1, \"Erstelldatum\"=@2, \"Strasse\"=@3, \"Ort\"=@4, \"ExportType\"=@5, \"Kodierungssystem\"=@6 WHERE \"Id\" = @8";
|
||||
using (var cmd = new NpgsqlCommand(command, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("1", entity.Projektname);
|
||||
cmd.Parameters.AddWithValue("2", entity.Erstelldatum);
|
||||
cmd.Parameters.AddWithValue("3", entity.Strasse);
|
||||
cmd.Parameters.AddWithValue("4", entity.Ort);
|
||||
cmd.Parameters.AddWithValue("5", (int)entity.ExportType);
|
||||
cmd.Parameters.AddWithValue("6", (int)entity.Kodierungssystem);
|
||||
cmd.Parameters.AddWithValue("8", entity.Id);
|
||||
int res = await cmd.ExecuteNonQueryAsync();
|
||||
Trace.WriteLine(res);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
109
SewerStammGen.DAL/Services/PostgresqlData/SchachtDataService.cs
Normal file
109
SewerStammGen.DAL/Services/PostgresqlData/SchachtDataService.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using Npgsql;
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
{
|
||||
public class SchachtDataService : PostgresqlDataService, ISchachtDataService
|
||||
{
|
||||
public SchachtDataService(string connectionstring) : base(connectionstring,"Schaechte")
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<Schacht> Create(Schacht entity)
|
||||
{
|
||||
string command = "INSERT INTO " + tableName + " (\"Objektbezeichnung\",\"RechtsWert\",\"HochWert\",\"SohlHoehe\",\"DeckelHoehe\",\"Entwaesserung\",\"ProjektId\") VALUES " +
|
||||
"(@1,@2,@3,@4,@5,@6,@7) RETURNING \"Id\"";
|
||||
using(var cmd = new NpgsqlCommand(command,conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("1", entity.Objektbezeichnung);
|
||||
cmd.Parameters.AddWithValue("2", entity.RechtsWert);
|
||||
cmd.Parameters.AddWithValue("3", entity.HochWert);
|
||||
cmd.Parameters.AddWithValue("4", entity.SohlHoehe);
|
||||
cmd.Parameters.AddWithValue("5", entity.DeckelHoehe);
|
||||
cmd.Parameters.AddWithValue("6", (int)entity.Entwaesserung);
|
||||
cmd.Parameters.AddWithValue("7", entity.Projekt.Id);
|
||||
using var reader = await cmd.ExecuteReaderAsync();
|
||||
reader.Read();
|
||||
entity.Id = reader.GetInt32(0);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
public Task<Schacht> Get(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<IEnumerable<Schacht>> GetAll()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private Schacht parseSchacht(NpgsqlDataReader? reader)
|
||||
{
|
||||
return new Schacht()
|
||||
{
|
||||
Id = reader.GetInt32(0),
|
||||
Objektbezeichnung = reader.IsDBNull(1) ? "": reader.GetString(1),
|
||||
RechtsWert = reader.GetDecimal(2),
|
||||
HochWert = reader.GetDecimal(3),
|
||||
SohlHoehe = reader.GetDecimal(4),
|
||||
DeckelHoehe = reader.GetDecimal(5),
|
||||
Entwaesserung = (EEntwaeserung)reader.GetInt32(6),
|
||||
Projekt = new Projekt() { Id = reader.GetInt32(7) },
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Schacht>> GetAllByProjekt(int projektID)
|
||||
{
|
||||
List<Schacht> result = new List<Schacht>();
|
||||
string command = @"SELECT * FROM " + tableName + " WHERE \"ProjektId\" = @1";
|
||||
using (var cmd = new NpgsqlCommand(command, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("1", projektID);
|
||||
using (var reader = await cmd.ExecuteReaderAsync())
|
||||
{
|
||||
while(reader.Read())
|
||||
{
|
||||
result.Add(parseSchacht(reader));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Schacht>> GetAllByProjekt(Projekt projekt)
|
||||
{
|
||||
return await GetAllByProjekt(projekt.Id);
|
||||
}
|
||||
|
||||
public async Task<Schacht> Update(Schacht entity)
|
||||
{
|
||||
string command = @"UPDATE " + tableName + "SET \"Objektbezeichnung\" =@1, \"RechtsWert\"=@2," +
|
||||
" \"HochWert\"=@3, \"SohlHoehe\"=@4, \"DeckelHoehe\"=@5, \"Entwaesserung\"=@6," +
|
||||
" \"ProjektId\"=@7 WHERE \"Id\"=@8";
|
||||
using(var cmd = new NpgsqlCommand(command,conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("1", entity.Objektbezeichnung);
|
||||
cmd.Parameters.AddWithValue("2", entity.RechtsWert);
|
||||
cmd.Parameters.AddWithValue("3", entity.HochWert);
|
||||
cmd.Parameters.AddWithValue("4", entity.SohlHoehe);
|
||||
cmd.Parameters.AddWithValue("5", entity.DeckelHoehe);
|
||||
cmd.Parameters.AddWithValue("6", (int)entity.Entwaesserung);
|
||||
cmd.Parameters.AddWithValue("7", entity.Projekt.Id);
|
||||
cmd.Parameters.AddWithValue("8", entity.Id);
|
||||
|
||||
await cmd.ExecuteNonQueryAsync();
|
||||
}
|
||||
return entity;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
22
SewerStammGen.DAL/SewerStammGen.DAL.csproj
Normal file
22
SewerStammGen.DAL/SewerStammGen.DAL.csproj
Normal file
@@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Npgsql" Version="7.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SewerStammGen.Shared\SewerStammGen.Shared.csproj" />
|
||||
<ProjectReference Include="..\Shared\SewerStammGen.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Services\SQLiteData\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,217 +0,0 @@
|
||||
// <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("20230328071830_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <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")
|
||||
.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");
|
||||
|
||||
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")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Objektbezeichnung")
|
||||
.IsRequired()
|
||||
.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<string>("Erstelldatum")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("ExportType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Kodierungssystem")
|
||||
.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");
|
||||
|
||||
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")
|
||||
.IsRequired()
|
||||
.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.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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SewerStammGen.EntityFramework.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Auftraggebers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
Strasse = table.Column<string>(type: "text", nullable: false),
|
||||
Ort = table.Column<string>(type: "text", nullable: false),
|
||||
Postleitzahl = table.Column<string>(type: "text", nullable: false),
|
||||
Ansprechpartner = table.Column<string>(type: "text", nullable: false),
|
||||
Telefonnummer = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Auftraggebers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Projekte",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Projektname = table.Column<string>(type: "text", nullable: false),
|
||||
Erstelldatum = table.Column<string>(type: "text", nullable: false),
|
||||
Strasse = table.Column<string>(type: "text", nullable: false),
|
||||
Ort = table.Column<string>(type: "text", nullable: false),
|
||||
ExportType = table.Column<int>(type: "integer", nullable: false),
|
||||
Kodierungssystem = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Projekte", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Schaechte",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Objektbezeichnung = table.Column<string>(type: "text", nullable: false),
|
||||
RechtsWert = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
HochWert = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
SohlHoehe = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
DeckelHoehe = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
Entwaesserung = table.Column<int>(type: "integer", nullable: false),
|
||||
ProjektId = table.Column<int>(type: "integer", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Schaechte", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Schaechte_Projekte_ProjektId",
|
||||
column: x => x.ProjektId,
|
||||
principalTable: "Projekte",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Kanaele",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Objektbezeichnung = table.Column<string>(type: "text", nullable: false),
|
||||
StartSchachtId = table.Column<int>(type: "integer", nullable: true),
|
||||
EndSchachtId = table.Column<int>(type: "integer", nullable: true),
|
||||
DN = table.Column<int>(type: "integer", nullable: false),
|
||||
Material = table.Column<string>(type: "text", nullable: false),
|
||||
Haltungslaenge = table.Column<decimal>(type: "numeric", nullable: false),
|
||||
Entwaesserung = table.Column<int>(type: "integer", nullable: false),
|
||||
ProjektId = table.Column<int>(type: "integer", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Kanaele", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Kanaele_Projekte_ProjektId",
|
||||
column: x => x.ProjektId,
|
||||
principalTable: "Projekte",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_Kanaele_Schaechte_EndSchachtId",
|
||||
column: x => x.EndSchachtId,
|
||||
principalTable: "Schaechte",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_Kanaele_Schaechte_StartSchachtId",
|
||||
column: x => x.StartSchachtId,
|
||||
principalTable: "Schaechte",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Kanaele_EndSchachtId",
|
||||
table: "Kanaele",
|
||||
column: "EndSchachtId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Kanaele_ProjektId",
|
||||
table: "Kanaele",
|
||||
column: "ProjektId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Kanaele_StartSchachtId",
|
||||
table: "Kanaele",
|
||||
column: "StartSchachtId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Schaechte_ProjektId",
|
||||
table: "Schaechte",
|
||||
column: "ProjektId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Auftraggebers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Kanaele");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Schaechte");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Projekte");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,233 +0,0 @@
|
||||
// <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("20230329145638_AuftraggeberAddedToProject")]
|
||||
partial class AuftraggeberAddedToProject
|
||||
{
|
||||
/// <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")
|
||||
.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");
|
||||
|
||||
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")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Objektbezeichnung")
|
||||
.IsRequired()
|
||||
.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")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int>("ExportType")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Kodierungssystem")
|
||||
.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");
|
||||
|
||||
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")
|
||||
.IsRequired()
|
||||
.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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SewerStammGen.EntityFramework.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AuftraggeberAddedToProject : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "AuftraggeberId",
|
||||
table: "Projekte",
|
||||
type: "integer",
|
||||
nullable: false,
|
||||
defaultValue: 0);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Projekte_AuftraggeberId",
|
||||
table: "Projekte",
|
||||
column: "AuftraggeberId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Projekte_Auftraggebers_AuftraggeberId",
|
||||
table: "Projekte",
|
||||
column: "AuftraggeberId",
|
||||
principalTable: "Auftraggebers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Projekte_Auftraggebers_AuftraggeberId",
|
||||
table: "Projekte");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Projekte_AuftraggeberId",
|
||||
table: "Projekte");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AuftraggeberId",
|
||||
table: "Projekte");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,220 +0,0 @@
|
||||
// <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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,252 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,222 +0,0 @@
|
||||
// <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("20230331095322_SchachtRefProject")]
|
||||
partial class SchachtRefProject
|
||||
{
|
||||
/// <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", "Projekt")
|
||||
.WithMany("Schaechte")
|
||||
.HasForeignKey("ProjektId");
|
||||
|
||||
b.Navigation("Projekt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Shared.Domain.Projekt", b =>
|
||||
{
|
||||
b.Navigation("Kanaele");
|
||||
|
||||
b.Navigation("Schaechte");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SewerStammGen.EntityFramework.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class SchachtRefProject : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using SewerStammGen.EntityFramework;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace SewerStammGen.EntityFramework.Migrations
|
||||
{
|
||||
[DbContext(typeof(SewerStammGenDbContext))]
|
||||
partial class SewerStammGenDbContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(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", (string)null);
|
||||
});
|
||||
|
||||
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", (string)null);
|
||||
});
|
||||
|
||||
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", (string)null);
|
||||
});
|
||||
|
||||
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", (string)null);
|
||||
});
|
||||
|
||||
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", "Projekt")
|
||||
.WithMany("Schaechte")
|
||||
.HasForeignKey("ProjektId");
|
||||
|
||||
b.Navigation("Projekt");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Shared.Domain.Projekt", b =>
|
||||
{
|
||||
b.Navigation("Kanaele");
|
||||
|
||||
b.Navigation("Schaechte");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.EntityFramework.Services.Common
|
||||
{
|
||||
class NonQueryDataService<T> where T: DBObject
|
||||
{
|
||||
private readonly SewerStammGenDbContextFactory _contextFactory;
|
||||
|
||||
public NonQueryDataService(SewerStammGenDbContextFactory contextFactory)
|
||||
{
|
||||
_contextFactory = contextFactory;
|
||||
}
|
||||
public async Task<T> Create(T entity)
|
||||
{
|
||||
using SewerStammGenDbContext context = _contextFactory.CreateDbContext();
|
||||
EntityEntry<T> createdEntity = await context.Set<T>().AddAsync(entity);
|
||||
await context.SaveChangesAsync();
|
||||
return createdEntity.Entity;
|
||||
}
|
||||
|
||||
public T CreateNonAsync(T entity)
|
||||
{
|
||||
using SewerStammGenDbContext context = _contextFactory.CreateDbContext();
|
||||
EntityEntry<T> createdEntity = context.Set<T>().Add(entity);
|
||||
context.SaveChanges();
|
||||
return createdEntity.Entity;
|
||||
}
|
||||
|
||||
public async Task<bool> Delete(int id)
|
||||
{
|
||||
using SewerStammGenDbContext context = _contextFactory.CreateDbContext();
|
||||
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;
|
||||
}
|
||||
public async Task<T> Update(int id, T entity)
|
||||
{
|
||||
using SewerStammGenDbContext context = _contextFactory.CreateDbContext();
|
||||
entity.Id = id;
|
||||
|
||||
context.Set<T>().Update(entity);
|
||||
await context.SaveChangesAsync();
|
||||
return entity;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SewerStammGen.EntityFramework.Services.Common;
|
||||
using Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.EntityFramework.Services
|
||||
{
|
||||
public class GenericDataService<T> : IDataService<T> where T : DBObject
|
||||
{
|
||||
private readonly SewerStammGenDbContextFactory _contextFactory;
|
||||
private readonly NonQueryDataService<T> _nonQueryDataService;
|
||||
|
||||
public GenericDataService(SewerStammGenDbContextFactory contextFactory)
|
||||
{
|
||||
_contextFactory = contextFactory;
|
||||
_nonQueryDataService = new NonQueryDataService<T>(contextFactory);
|
||||
}
|
||||
|
||||
public async Task<T> Create(T entity)
|
||||
{
|
||||
return await _nonQueryDataService.Create(entity);
|
||||
}
|
||||
|
||||
public T CreateNonAsync(T entity)
|
||||
{
|
||||
return _nonQueryDataService.CreateNonAsync(entity);
|
||||
}
|
||||
|
||||
public async Task<bool> Delete(int id)
|
||||
{
|
||||
return await (_nonQueryDataService.Delete(id));
|
||||
}
|
||||
|
||||
public async Task<T> Get(int id)
|
||||
{
|
||||
using(SewerStammGenDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
T entity = await context.Set<T>().FirstOrDefaultAsync((e) => e.Id == id);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<T>> GetAll()
|
||||
{
|
||||
using (SewerStammGenDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
IEnumerable<T> entities = await context.Set<T>().ToListAsync();
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<T> Update(int id, T entity)
|
||||
{
|
||||
return await _nonQueryDataService.Update(id, entity);
|
||||
}
|
||||
|
||||
T IDataService<T>.CreateNonAsync(T entity)
|
||||
{
|
||||
return _nonQueryDataService.CreateNonAsync(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SewerStammGen.EntityFramework.Services.Common;
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.EntityFramework.Services
|
||||
{
|
||||
public class HaltungDataService : IHaltungDataService
|
||||
{
|
||||
private readonly SewerStammGenDbContextFactory _contextFactory;
|
||||
private readonly NonQueryDataService<Kanal> _nonQueryDataService;
|
||||
|
||||
public HaltungDataService(SewerStammGenDbContextFactory contextFactory)
|
||||
{
|
||||
_contextFactory = contextFactory;
|
||||
_nonQueryDataService = new NonQueryDataService<Kanal>(contextFactory);
|
||||
}
|
||||
public async Task<Kanal> Create(Kanal entity)
|
||||
{
|
||||
return await _nonQueryDataService.Create(entity);
|
||||
}
|
||||
|
||||
public Kanal CreateNonAsync(Kanal entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<bool> Delete(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<Kanal> Get(int id)
|
||||
{
|
||||
using (SewerStammGenDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
Kanal entity = await context.Set<Kanal>()
|
||||
.Include("StartSchacht")
|
||||
.Include("EndSchacht")
|
||||
.Include("Projekt")
|
||||
.FirstOrDefaultAsync((e) => e.Id == id);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Kanal>> GetAll(int projektID)
|
||||
{
|
||||
using (SewerStammGenDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
IEnumerable<Kanal> entities = await context.Set<Kanal>().Where(x => x.Projekt.Id.Equals(projektID)).ToListAsync();
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<IEnumerable<Kanal>> GetAll()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<Kanal> Update(int id, Kanal entity)
|
||||
{
|
||||
return await _nonQueryDataService.Update(id, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SewerStammGen.EntityFramework.Services.Common;
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.EntityFramework.Services
|
||||
{
|
||||
public class SchachtDataService : ISchachtDataService
|
||||
{
|
||||
private readonly SewerStammGenDbContextFactory _contextFactory;
|
||||
private readonly NonQueryDataService<Schacht> _nonQueryDataService;
|
||||
|
||||
public SchachtDataService(SewerStammGenDbContextFactory contextFactory)
|
||||
{
|
||||
_contextFactory = contextFactory;
|
||||
_nonQueryDataService = new NonQueryDataService<Schacht>(contextFactory);
|
||||
}
|
||||
|
||||
public async Task<Schacht> Create(Schacht entity)
|
||||
{
|
||||
return await _nonQueryDataService.Create(entity);
|
||||
}
|
||||
|
||||
public Schacht CreateNonAsync(Schacht entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<bool> Delete(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<Schacht> Get(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Schacht>> GetAll(int projektID)
|
||||
{
|
||||
using (SewerStammGenDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
IEnumerable<Schacht> entities = await context.Set<Schacht>().Where(x => x.Projekt.Id.Equals(projektID)).ToListAsync();
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<IEnumerable<Schacht>> GetAll()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<Schacht> GetSchachtByNameAndProjekt(string name, int projektID)
|
||||
{
|
||||
using(SewerStammGenDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
Schacht entity = await context.Set<Schacht>().Where(x => x.Projekt.Id.Equals(projektID) && x.Objektbezeichnung.Equals(name)).FirstOrDefaultAsync();
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Schacht> Update(int id, Schacht entity)
|
||||
{
|
||||
return await _nonQueryDataService.Update(id, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\SewerStammGen.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,20 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shared.Domain;
|
||||
|
||||
namespace SewerStammGen.EntityFramework
|
||||
{
|
||||
public class SewerStammGenDbContext : DbContext
|
||||
{
|
||||
public SewerStammGenDbContext(DbContextOptions options) : base(options) { }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
|
||||
public DbSet<Schacht>? Schaechte { get; set; }
|
||||
public DbSet<Projekt>? Projekte { get; set; }
|
||||
public DbSet<Kanal>? Kanaele { get; set; }
|
||||
public DbSet<Auftraggeber>? Auftraggebers { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.EntityFramework
|
||||
{
|
||||
public class SewerStammGenDbContextFactory : IDesignTimeDbContextFactory<SewerStammGenDbContext>
|
||||
{
|
||||
private readonly Action<DbContextOptionsBuilder> _configureDbContext;
|
||||
|
||||
public SewerStammGenDbContextFactory() { }
|
||||
|
||||
public SewerStammGenDbContextFactory(Action<DbContextOptionsBuilder> configureDbContext)
|
||||
{
|
||||
_configureDbContext = configureDbContext;
|
||||
}
|
||||
|
||||
public SewerStammGenDbContext CreateDbContext()
|
||||
{
|
||||
DbContextOptionsBuilder<SewerStammGenDbContext>? options = new();
|
||||
_configureDbContext( options );
|
||||
return new SewerStammGenDbContext(options.Options);
|
||||
}
|
||||
|
||||
public SewerStammGenDbContext CreateDbContext(string[] args)
|
||||
{
|
||||
var options = new DbContextOptionsBuilder<SewerStammGenDbContext>();
|
||||
options.UseNpgsql("Host = localhost; Database = SewerGen; Username = SewerGen; Password = SewerGen");
|
||||
SewerStammGenDbContext result = new(options.Options);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
14
SewerStammGen.Shared/Contracts/IAuftraggeberDataService.cs
Normal file
14
SewerStammGen.Shared/Contracts/IAuftraggeberDataService.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using Shared.Contracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.Shared.Contracts
|
||||
{
|
||||
public interface IAuftraggeberDataService : IDataService<Auftraggeber>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Shared.Contracts
|
||||
{
|
||||
public interface IDataService<T>
|
||||
public interface IDataService<T>: IDisposable
|
||||
{
|
||||
Task<IEnumerable<T>> GetAll();
|
||||
Task<T> Get(int id);
|
||||
Task<T> Create(T entity);
|
||||
Task<T> Update(int id,T entity);
|
||||
Task<T> Update(T entity);
|
||||
Task<bool> Delete(int id);
|
||||
T CreateNonAsync(T entity);
|
||||
//T CreateNonAsync(T entity);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using Shared.Contracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -10,6 +10,7 @@ namespace SewerStammGen.Shared.Contracts
|
||||
{
|
||||
public interface IHaltungDataService : IDataService<Kanal>
|
||||
{
|
||||
Task<IEnumerable<Kanal>> GetAll(int projektID);
|
||||
Task<IEnumerable<Kanal>> GetAllByProjekt(int projektID);
|
||||
Task<IEnumerable<Kanal>> GetAllByProjekt(Projekt projekt);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using Shared.Contracts;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -1,5 +1,6 @@
|
||||
using Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using Shared.Contracts;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -10,7 +11,7 @@ namespace SewerStammGen.Shared.Contracts
|
||||
{
|
||||
public interface ISchachtDataService : IDataService<Schacht>
|
||||
{
|
||||
Task<IEnumerable<Schacht>> GetAll(int projektID);
|
||||
Task<Schacht> GetSchachtByNameAndProjekt(string name, int projektID);
|
||||
Task<IEnumerable<Schacht>> GetAllByProjekt(int projektID);
|
||||
Task<IEnumerable<Schacht>> GetAllByProjekt(Projekt projekt);
|
||||
}
|
||||
}
|
||||
18
SewerStammGen.Shared/Domain/Auftraggeber.cs
Normal file
18
SewerStammGen.Shared/Domain/Auftraggeber.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.Shared.Domain
|
||||
{
|
||||
public class Auftraggeber : DBObject
|
||||
{
|
||||
public string Name { get; set; } = String.Empty;
|
||||
public string Strasse { get; set; } = String.Empty;
|
||||
public string Ort { get; set; } = String.Empty;
|
||||
public string Postleitzahl { get; set; } = String.Empty;
|
||||
public string Ansprechpartner { get; set; } = String.Empty;
|
||||
public string Telefonnummer { get; set; } = String.Empty;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Shared.Domain
|
||||
namespace SewerStammGen.Shared.Domain
|
||||
{
|
||||
public class DBObject
|
||||
{
|
||||
21
SewerStammGen.Shared/Domain/Kanal.cs
Normal file
21
SewerStammGen.Shared/Domain/Kanal.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.Shared.Domain
|
||||
{
|
||||
public class Kanal : DBObject
|
||||
{
|
||||
public string Objektbezeichnung { get; set; } = String.Empty;
|
||||
public Schacht StartSchacht { get; set; } = new Schacht();
|
||||
public Schacht EndSchacht { get; set; } = new Schacht();
|
||||
public int DN { get; set; }
|
||||
public string Material { get; set; } = String.Empty;
|
||||
public decimal Haltungslaenge { get; set; }
|
||||
public Projekt Projekt { get; set; } = new Projekt();
|
||||
public EEntwaeserung Entwaesserung { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,19 @@
|
||||
using Shared.Enum;
|
||||
|
||||
using SewerStammGen.Shared.Enum;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Shared.Domain
|
||||
namespace SewerStammGen.Shared.Domain
|
||||
{
|
||||
public class Projekt : DBObject
|
||||
{
|
||||
public string? Projektname { get; set; }
|
||||
public string? Erstelldatum { get; set; }
|
||||
public string? Strasse { get;set; }
|
||||
public string? Ort { get; set; }
|
||||
public string Projektname { get; set; } = String.Empty;
|
||||
public string Erstelldatum { get; set; } = String.Empty;
|
||||
public string Strasse { get; set; } = String.Empty;
|
||||
public string Ort { get; set; } = String.Empty;
|
||||
public Auftraggeber Auftraggeber { get; set; }
|
||||
public EExportType ExportType { get; set; }
|
||||
public EKodierungssystem Kodierungssystem { get; set; }
|
||||
@@ -5,25 +5,16 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Shared.Domain
|
||||
namespace SewerStammGen.Shared.Domain
|
||||
{
|
||||
public class Schacht : DBObject
|
||||
{
|
||||
public string? Objektbezeichnung { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public string Objektbezeichnung { get; set; } = String.Empty;
|
||||
public decimal RechtsWert { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal HochWert { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal SohlHoehe { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal DeckelHoehe { get; set; }
|
||||
|
||||
public virtual Projekt? Projekt { get; set; }
|
||||
public Projekt Projekt { get; set; } = new Projekt();
|
||||
public EEntwaeserung Entwaesserung { get; set; }
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Shared.Enum
|
||||
namespace SewerStammGen.Shared.Enum
|
||||
{
|
||||
public enum EExportType
|
||||
{
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Shared.Enum
|
||||
namespace SewerStammGen.Shared.Enum
|
||||
{
|
||||
public enum EKodierungssystem
|
||||
{
|
||||
@@ -6,4 +6,10 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Services\**" />
|
||||
<EmbeddedResource Remove="Services\**" />
|
||||
<None Remove="Services\**" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,7 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using SewerStammGen.EntityFramework;
|
||||
using SewerStammGen.HostBuilders;
|
||||
using SewerStammGen.WPF.ViewModel;
|
||||
using System;
|
||||
@@ -31,8 +29,8 @@ namespace SewerStammGen.WPF
|
||||
.AddConfiguration()
|
||||
.AddServices()
|
||||
.AddViewModels()
|
||||
.AddStores()
|
||||
.AddDBContext();
|
||||
.AddStores();
|
||||
|
||||
}
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
@@ -42,11 +40,7 @@ namespace SewerStammGen.WPF
|
||||
|
||||
_host.Start();
|
||||
|
||||
SewerStammGenDbContextFactory contextFactory = _host.Services.GetRequiredService<SewerStammGenDbContextFactory>();
|
||||
using(SewerStammGenDbContext context = contextFactory.CreateDbContext())
|
||||
{
|
||||
context.Database.Migrate();
|
||||
}
|
||||
|
||||
|
||||
MainWindow? window = new MainWindow() { DataContext = _host.Services.GetRequiredService<MainWindowViewModel>() };
|
||||
window.Show();
|
||||
@@ -59,7 +53,7 @@ namespace SewerStammGen.WPF
|
||||
try
|
||||
{
|
||||
Exception ex = (Exception)e.ExceptionObject;
|
||||
string text = "An application error occured. Plrease contact the Administrator with the following information:\n\n";
|
||||
string text = "An application error occured. Please contact the Administrator with the following information:\n\n";
|
||||
MessageBox.Show(text + " " + ex.Message + "\n\n" + ex.StackTrace);
|
||||
}
|
||||
catch (Exception ex2)
|
||||
@@ -12,15 +12,15 @@ namespace SewerStammGen.WPF.Commands
|
||||
{
|
||||
internal class HaltungEditCommand : AsyncCommandBase
|
||||
{
|
||||
private IHaltungDataService haltungDataService;
|
||||
|
||||
private IActualState actualState;
|
||||
private IRenavigator renavigator;
|
||||
private HaltungListViewModel haltungListViewModel;
|
||||
|
||||
|
||||
public HaltungEditCommand(IHaltungDataService haltungDataService, IActualState actualState, IRenavigator renavigator, HaltungListViewModel haltungListViewModel)
|
||||
public HaltungEditCommand(IActualState actualState, IRenavigator renavigator, HaltungListViewModel haltungListViewModel)
|
||||
{
|
||||
this.haltungDataService = haltungDataService;
|
||||
|
||||
this.actualState = actualState;
|
||||
this.renavigator = renavigator;
|
||||
this.haltungListViewModel = haltungListViewModel;
|
||||
35
SewerStammGen.WPF/Commands/HaltungEditSaveCommand.cs
Normal file
35
SewerStammGen.WPF/Commands/HaltungEditSaveCommand.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.WPF.ViewModel;
|
||||
using Shared.Contracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.WPF.Commands
|
||||
{
|
||||
internal class HaltungEditSaveCommand : AsyncCommandBase
|
||||
{
|
||||
private readonly HaltungEditViewModel _haltungEditViewModel;
|
||||
private readonly IHaltungDataService _haltungDataService;
|
||||
private readonly IRenavigator _renavigator;
|
||||
|
||||
public HaltungEditSaveCommand(IHaltungDataService haltungDataService,IRenavigator renavigator,HaltungEditViewModel haltungEditViewModel)
|
||||
{
|
||||
this._haltungEditViewModel = haltungEditViewModel;
|
||||
this._haltungDataService = haltungDataService;
|
||||
this._renavigator = renavigator;
|
||||
}
|
||||
|
||||
public override async Task ExecuteAsync(object? parameter)
|
||||
{
|
||||
_haltungEditViewModel.Model = await _haltungDataService.Update(_haltungEditViewModel.Model);
|
||||
|
||||
_renavigator.Renavigate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.WPF.ViewModel.State;
|
||||
using Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -13,10 +14,10 @@ namespace SewerStammGen.WPF.Commands
|
||||
internal class ProjektAddCommand : AsyncCommandBase
|
||||
{
|
||||
private readonly IActualState _actualState;
|
||||
private readonly IDataService<Projekt> _generic;
|
||||
private readonly IProjektDataService _generic;
|
||||
private readonly IRenavigator _renavigator;
|
||||
|
||||
public ProjektAddCommand(IDataService<Projekt> generic, IActualState actualState, IRenavigator renavigator)
|
||||
public ProjektAddCommand(IProjektDataService generic, IActualState actualState, IRenavigator renavigator)
|
||||
{
|
||||
_renavigator = renavigator;
|
||||
_generic = generic;
|
||||
@@ -35,7 +36,7 @@ namespace SewerStammGen.WPF.Commands
|
||||
Schaechte = new List<Schacht>(),
|
||||
Kanaele = new List<Kanal>()
|
||||
};
|
||||
//newProjekt = await _generic.Create(newProjekt);
|
||||
newProjekt = await _generic.Create(newProjekt);
|
||||
_actualState.SetProjekt(newProjekt);
|
||||
_renavigator.Renavigate();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.WPF.ViewModel;
|
||||
using SewerStammGen.WPF.ViewModel.State;
|
||||
using Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using SewerStammGen.WPF.ViewModel;
|
||||
using SewerStammGen.WPF.ViewModel.State;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.WPF.ViewModel.State;
|
||||
using Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -15,23 +15,22 @@ namespace SewerStammGen.WPF.Commands
|
||||
{
|
||||
private readonly IActualState actualState;
|
||||
private readonly IRenavigator renavigator;
|
||||
private readonly IDataService<Projekt> projektService;
|
||||
private readonly ISchachtService schachtService;
|
||||
|
||||
|
||||
public SchachtAddCommand(IDataService<Projekt> projektService, IActualState actualState, IRenavigator renavigator, ISchachtService schachtService)
|
||||
public SchachtAddCommand(IActualState actualState, IRenavigator renavigator)
|
||||
{
|
||||
this.actualState = actualState;
|
||||
this.renavigator = renavigator;
|
||||
this.projektService = projektService;
|
||||
this.schachtService = schachtService;
|
||||
}
|
||||
|
||||
public override async Task ExecuteAsync(object? parameter)
|
||||
{
|
||||
Projekt aktuelleProjekt = await projektService.Get(actualState.ProjektID);
|
||||
Schacht schacht = await schachtService.CreateSchacht(aktuelleProjekt);
|
||||
|
||||
Schacht newSchacht = new Schacht()
|
||||
{
|
||||
Projekt = new Projekt() { Id = actualState.ProjektID },
|
||||
};
|
||||
actualState.SetSchacht(newSchacht);
|
||||
renavigator.Renavigate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,14 +12,13 @@ namespace SewerStammGen.WPF.Commands
|
||||
{
|
||||
class SchachtEditCommand : AsyncCommandBase
|
||||
{
|
||||
private ISchachtDataService schachtService;
|
||||
|
||||
private IActualState actualState;
|
||||
private IRenavigator renavigator;
|
||||
private ManholeListViewModel manholeListViewModel;
|
||||
|
||||
public SchachtEditCommand(ISchachtDataService schachtService, IActualState actualState, IRenavigator renavigator, ManholeListViewModel manholeListViewModel)
|
||||
public SchachtEditCommand(IActualState actualState, IRenavigator renavigator, ManholeListViewModel manholeListViewModel)
|
||||
{
|
||||
this.schachtService = schachtService;
|
||||
this.actualState = actualState;
|
||||
this.renavigator = renavigator;
|
||||
this.manholeListViewModel = manholeListViewModel;
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.HostBuilders
|
||||
{
|
||||
static class AddDBContextHostBuilderExtensions
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.WPF.ViewModel;
|
||||
using SewerStammGen.WPF.ViewModel.State.Navigation;
|
||||
using Shared.Contracts;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.HostBuilders
|
||||
{
|
||||
internal static class AddServicesHostBuilderExtensions
|
||||
{
|
||||
public static IHostBuilder AddServices(this IHostBuilder host)
|
||||
{
|
||||
host.ConfigureServices((context,services) =>
|
||||
{
|
||||
services.AddSingleton<IMainWindowNavigator, MainWindowNavigator>();
|
||||
services.AddSingleton<ViewModelDelegateRenavigator<ProjektEditViewModel>>();
|
||||
|
||||
string? databaseToUse = context.Configuration.GetConnectionString("databaseToUse");
|
||||
if(databaseToUse != null)
|
||||
{
|
||||
if(databaseToUse.Equals("postgresql"))
|
||||
{
|
||||
string? connectionstring = context.Configuration.GetConnectionString("postgresql");
|
||||
if(connectionstring == null) throw new ArgumentNullException(nameof(connectionstring));
|
||||
services.AddSingleton<IProjektDataService>(_=> new DAL.Services.PostgresqlData.ProjektDataService(connectionstring));
|
||||
services.AddSingleton<IAuftraggeberDataService>(_ => new DAL.Services.PostgresqlData.AuftraggeberDataService(connectionstring));
|
||||
services.AddSingleton<ISchachtDataService>(_ => new DAL.Services.PostgresqlData.SchachtDataService(connectionstring));
|
||||
services.AddSingleton<IHaltungDataService>(_ => new DAL.Services.PostgresqlData.HaltungDataService(connectionstring));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
return host;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ using SewerStammGen.WPF.ViewModel;
|
||||
using SewerStammGen.WPF.ViewModel.State.Navigation;
|
||||
using SewerStammGen.WPF.ViewModel.Factories;
|
||||
using Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -15,6 +14,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SewerStammGen.WPF.ViewModel.State;
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
|
||||
namespace SewerStammGen.HostBuilders
|
||||
{
|
||||
@@ -46,18 +46,18 @@ namespace SewerStammGen.HostBuilders
|
||||
{
|
||||
return () => new ManholeListViewModel(
|
||||
services.GetRequiredService<ISchachtDataService>(),
|
||||
services.GetRequiredService<IDataService<Projekt>>(),
|
||||
services.GetRequiredService<ViewModelDelegateRenavigator<ManholeEditViewModel>>(),
|
||||
services.GetRequiredService<IActualState>(),
|
||||
services.GetRequiredService<ISchachtService>()
|
||||
services.GetRequiredService<IActualState>()
|
||||
|
||||
);
|
||||
});
|
||||
|
||||
services.AddSingleton<CreateViewModel<ManholeEditViewModel>>(services =>
|
||||
{
|
||||
return () => new ManholeEditViewModel(
|
||||
services.GetRequiredService<IDataService<Schacht>>(),
|
||||
services.GetRequiredService<IActualState>()
|
||||
services.GetRequiredService<ISchachtDataService>(),
|
||||
services.GetRequiredService<IActualState>(),
|
||||
services.GetRequiredService<ViewModelDelegateRenavigator<ManholeListViewModel>>()
|
||||
);
|
||||
});
|
||||
#endregion
|
||||
@@ -76,8 +76,8 @@ namespace SewerStammGen.HostBuilders
|
||||
{
|
||||
return () => new HaltungEditViewModel(
|
||||
services.GetRequiredService<IHaltungDataService>(),
|
||||
services.GetRequiredService<ISchachtService>(),
|
||||
services.GetRequiredService<IActualState>()
|
||||
services.GetRequiredService<IActualState>(),
|
||||
services.GetRequiredService<ViewModelDelegateRenavigator<HaltungListViewModel>>()
|
||||
);
|
||||
});
|
||||
#endregion
|
||||
@@ -86,7 +86,7 @@ namespace SewerStammGen.HostBuilders
|
||||
services.AddSingleton<CreateViewModel<ProjektEditViewModel>>(services =>
|
||||
{
|
||||
return () => new ProjektEditViewModel(
|
||||
services.GetRequiredService<IDataService<Projekt>>(),
|
||||
services.GetRequiredService<IProjektDataService>(),
|
||||
services.GetRequiredService<ViewModelDelegateRenavigator<ProjektListViewModel>>(),
|
||||
services.GetRequiredService<IActualState>()
|
||||
);
|
||||
@@ -95,7 +95,7 @@ namespace SewerStammGen.HostBuilders
|
||||
services.AddSingleton<CreateViewModel<ProjektListViewModel>>(services =>
|
||||
{
|
||||
return () => new ProjektListViewModel(
|
||||
services.GetRequiredService<IDataService<Projekt>>(),
|
||||
services.GetRequiredService<IProjektDataService>(),
|
||||
services.GetRequiredService<ViewModelDelegateRenavigator<ProjektEditViewModel>>(),
|
||||
services.GetRequiredService<IActualState>()
|
||||
);
|
||||
@@ -8,10 +8,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
|
||||
@@ -19,7 +15,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SewerStammGen.EntityFramework\SewerStammGen.EntityFramework.csproj" />
|
||||
<ProjectReference Include="..\SewerStammGen.DAL\SewerStammGen.DAL.csproj" />
|
||||
<ProjectReference Include="..\SewerStammGen.Shared\SewerStammGen.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -1,8 +1,9 @@
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.WPF.Commands;
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.WPF.ViewModel.State;
|
||||
using Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -17,8 +18,8 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
internal class HaltungEditViewModel : BaseViewModel
|
||||
{
|
||||
private readonly IActualState _actualState;
|
||||
private readonly IHaltungDataService _kanalDataService;
|
||||
private readonly ISchachtService _schachtService;
|
||||
private readonly IHaltungDataService _haltungDataService;
|
||||
|
||||
private Kanal _model;
|
||||
|
||||
public Kanal Model
|
||||
@@ -112,32 +113,21 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
|
||||
public ICommand Speichern { get; set; }
|
||||
|
||||
public HaltungEditViewModel(IHaltungDataService kanalDataService,
|
||||
ISchachtService schachtService,
|
||||
IActualState actualState)
|
||||
public HaltungEditViewModel(
|
||||
IHaltungDataService haltungDataService,
|
||||
IActualState actualState,
|
||||
IRenavigator renavigator)
|
||||
{
|
||||
_actualState = actualState;
|
||||
_kanalDataService = kanalDataService;
|
||||
_schachtService = schachtService;
|
||||
_model = new Kanal();
|
||||
Speichern = new HaltungEditSaveCommand(this, kanalDataService, schachtService);
|
||||
_haltungDataService = haltungDataService;
|
||||
|
||||
LoadModel();
|
||||
_model = _actualState.SelectedHaltung;
|
||||
_oberePunkt = _model.StartSchacht.Objektbezeichnung;
|
||||
_unterePunkt = _model.EndSchacht.Objektbezeichnung;
|
||||
Speichern = new HaltungEditSaveCommand(_haltungDataService,renavigator,this);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private async void LoadModel()
|
||||
{
|
||||
_model = await _kanalDataService.Get(_actualState.HaltungID);
|
||||
UntereSchacht = _model.EndSchacht.Objektbezeichnung;
|
||||
ObereSchacht = _model.StartSchacht.Objektbezeichnung;
|
||||
OnPropertyChanged(nameof(ObereSchacht));
|
||||
OnPropertyChanged(nameof(UntereSchacht));
|
||||
OnPropertyChanged(nameof(Haltungslaenge));
|
||||
OnPropertyChanged(nameof(Haltungsbezeichnung));
|
||||
OnPropertyChanged(nameof(Material));
|
||||
OnPropertyChanged(nameof(Durchmesser));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.WPF.Commands;
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.WPF.ViewModel.State;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -28,11 +28,12 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
public HaltungListViewModel(IHaltungDataService haltungDataService, IActualState actualState, IRenavigator renavigator )
|
||||
{
|
||||
_haltungen = new ObservableCollection<Kanal>();
|
||||
|
||||
_actualState = actualState;
|
||||
_haltungDataService = haltungDataService;
|
||||
|
||||
EditCommand = new HaltungEditCommand(haltungDataService, actualState, renavigator, this);
|
||||
_actualState = actualState;
|
||||
|
||||
|
||||
EditCommand = new HaltungEditCommand(actualState, renavigator, this);
|
||||
AddCommand = new HaltungAddCommand();
|
||||
|
||||
LoadHaltungen();
|
||||
@@ -40,8 +41,9 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
|
||||
private async void LoadHaltungen()
|
||||
{
|
||||
var haltungen = await _haltungDataService.GetAll(_actualState.ProjektID);
|
||||
var haltungen = await _haltungDataService.GetAllByProjekt(_actualState.ProjektID);
|
||||
InitCollection(_haltungen, haltungen);
|
||||
|
||||
}
|
||||
|
||||
private void InitCollection(ObservableCollection<Kanal> dest, IEnumerable<Kanal> source)
|
||||
@@ -1,7 +1,7 @@
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.WPF.ViewModel.State;
|
||||
using Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -103,14 +103,8 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
|
||||
private void SaveProject()
|
||||
{
|
||||
if (_model.Id == 0) // Handelt sich um ein neuen Eintrag
|
||||
{
|
||||
_dataService.Create(_model);
|
||||
}
|
||||
else
|
||||
{
|
||||
_dataService.Update(_model.Id, _model);
|
||||
}
|
||||
_dataService.Update(_model);
|
||||
|
||||
_renavigator.Renavigate();
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
using SewerStammGen.EntityFramework.Services;
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.WPF.Commands;
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.WPF.ViewModel;
|
||||
using SewerStammGen.WPF.ViewModel.State;
|
||||
using Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -17,7 +17,7 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
{
|
||||
public class ProjektListViewModel : BaseViewModel
|
||||
{
|
||||
private IDataService<Projekt> genericDataService;
|
||||
private IProjektDataService genericDataService;
|
||||
private readonly ObservableCollection<Projekt> _projekte;
|
||||
private readonly IActualState _actualState;
|
||||
public ObservableCollection<Projekt> Projekte { get => _projekte; }
|
||||
@@ -45,7 +45,7 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public ProjektListViewModel(IDataService<Projekt> generic, IRenavigator renavigator,IActualState actualState)
|
||||
public ProjektListViewModel(IProjektDataService generic, IRenavigator renavigator,IActualState actualState)
|
||||
{
|
||||
_projekte = new ObservableCollection<Projekt>();
|
||||
if (generic == null) throw new ArgumentNullException(nameof(generic));
|
||||
@@ -61,7 +61,9 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
private async void LoadProjekte()
|
||||
{
|
||||
var projects = await genericDataService.GetAll();
|
||||
|
||||
InitCollection(_projekte, projects);
|
||||
|
||||
}
|
||||
|
||||
private void InitCollection(ObservableCollection<Projekt> projekte, IEnumerable<Projekt> projects)
|
||||
@@ -1,6 +1,8 @@
|
||||
using SewerStammGen.WPF.ViewModel.State;
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.WPF.ViewModel.State;
|
||||
using Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -12,8 +14,8 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
{
|
||||
public class ManholeEditViewModel : BaseViewModel
|
||||
{
|
||||
private readonly IActualState _actualState;
|
||||
private readonly IDataService<Schacht> _schachtDataService;
|
||||
private readonly ISchachtDataService _schachtDataService;
|
||||
private readonly IRenavigator _renavigator;
|
||||
|
||||
private Schacht _model;
|
||||
|
||||
@@ -94,33 +96,27 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public ManholeEditViewModel(IDataService<Schacht> schachtDataService,IActualState actualState)
|
||||
public ManholeEditViewModel(ISchachtDataService schachtDataService,IActualState actualState, IRenavigator renavigator)
|
||||
{
|
||||
_actualState = actualState;
|
||||
_schachtDataService = schachtDataService;
|
||||
_model = new Schacht();
|
||||
_model = actualState.SelectedSchacht;
|
||||
_renavigator = renavigator;
|
||||
|
||||
Speichern = new RelayCommand((x) => SaveSchacht());
|
||||
|
||||
LoadModel();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void SaveSchacht()
|
||||
private async void SaveSchacht()
|
||||
{
|
||||
_schachtDataService.Update(_model.Id, _model);
|
||||
}
|
||||
|
||||
private async void LoadModel()
|
||||
{
|
||||
_model = await _schachtDataService.Get(_actualState.SchachtID);
|
||||
OnPropertyChanged(nameof(Entwaeserung));
|
||||
OnPropertyChanged(nameof(Objektbezeichnung));
|
||||
OnPropertyChanged(nameof(HochWert));
|
||||
OnPropertyChanged(nameof(RechtsWert));
|
||||
OnPropertyChanged(nameof(DeckelHoehe));
|
||||
OnPropertyChanged(nameof(SohlHoehe));
|
||||
if (_model.Id == 0)
|
||||
{
|
||||
await _schachtDataService.Create(_model);
|
||||
}
|
||||
else
|
||||
{
|
||||
await _schachtDataService.Update(_model);
|
||||
}
|
||||
_renavigator.Renavigate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.WPF.Commands;
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.WPF.ViewModel.State;
|
||||
using Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -16,10 +16,10 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
{
|
||||
public class ManholeListViewModel : BaseViewModel
|
||||
{
|
||||
private ISchachtDataService _schachtDataService;
|
||||
private readonly ISchachtDataService _schachtDataService;
|
||||
private readonly ObservableCollection<Schacht> _schaechte;
|
||||
private readonly IActualState _actualState;
|
||||
private readonly ISchachtService _schachtService;
|
||||
|
||||
public ObservableCollection<Schacht> Schaechte { get => _schaechte; }
|
||||
|
||||
public Schacht? SelectedSchacht { get; set; }
|
||||
@@ -29,16 +29,16 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
public ICommand DeleteSchachtCommand { get; set; }
|
||||
|
||||
|
||||
public ManholeListViewModel(ISchachtDataService schachtDataService, IDataService<Projekt> projektService,IRenavigator renavigator ,IActualState actualState, ISchachtService schachtService)
|
||||
public ManholeListViewModel(ISchachtDataService schachtDataService, IRenavigator renavigator ,IActualState actualState)
|
||||
{
|
||||
_schachtDataService = schachtDataService;
|
||||
_actualState = actualState;
|
||||
|
||||
_schaechte = new ObservableCollection<Schacht>();
|
||||
_schachtService = schachtService;
|
||||
|
||||
|
||||
AddSchachtCommand = new SchachtAddCommand(projektService, actualState,renavigator,schachtService);
|
||||
EditSchachtCommand = new SchachtEditCommand(schachtDataService, actualState, renavigator,this);
|
||||
AddSchachtCommand = new SchachtAddCommand(actualState,renavigator);
|
||||
EditSchachtCommand = new SchachtEditCommand(actualState, renavigator,this);
|
||||
DeleteSchachtCommand = new SchachtDeleteCommand(schachtDataService, actualState, renavigator, this);
|
||||
|
||||
LoadSchaechte();
|
||||
@@ -46,7 +46,7 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
|
||||
private async void LoadSchaechte()
|
||||
{
|
||||
var schaechte = await _schachtDataService.GetAll(_actualState.ProjektID);
|
||||
var schaechte = await _schachtDataService.GetAllByProjekt(_actualState.ProjektID);
|
||||
InitCollection(_schaechte, schaechte);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Shared.Domain;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -14,6 +14,9 @@ namespace SewerStammGen.WPF.ViewModel.State
|
||||
|
||||
public int SchachtID { get; private set; }
|
||||
public int HaltungID { get; private set; }
|
||||
public Schacht SelectedSchacht { get; private set; }
|
||||
|
||||
public Kanal SelectedHaltung {get; private set; }
|
||||
|
||||
public void SetProjekt(Projekt projekt, bool notification = true)
|
||||
{
|
||||
@@ -25,6 +28,7 @@ namespace SewerStammGen.WPF.ViewModel.State
|
||||
}
|
||||
public void SetSchacht(Schacht schacht, bool notification = true)
|
||||
{
|
||||
SelectedSchacht = schacht;
|
||||
SchachtID = schacht.Id;
|
||||
if(notification)
|
||||
{
|
||||
@@ -33,6 +37,7 @@ namespace SewerStammGen.WPF.ViewModel.State
|
||||
}
|
||||
public void SetHaltung(Kanal haltung, bool notification = true)
|
||||
{
|
||||
SelectedHaltung = haltung;
|
||||
HaltungID = haltung.Id;
|
||||
if(notification)
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
using Shared.Domain;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -14,6 +14,8 @@ namespace SewerStammGen.WPF.ViewModel.State
|
||||
int ProjektID { get; set; }
|
||||
int SchachtID { get; }
|
||||
int HaltungID { get; }
|
||||
Schacht SelectedSchacht { get; }
|
||||
Kanal SelectedHaltung { get; }
|
||||
|
||||
void SetProjekt(Projekt projekt, bool notification = true);
|
||||
void SetSchacht(Schacht schacht, bool notification = true);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user