Gui neu angelegt
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Npgsql;
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.Shared.Enum;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -16,9 +17,27 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
{
|
||||
}
|
||||
|
||||
public Task<Kanal> Create(Kanal entity)
|
||||
public async Task<Kanal> Create(Kanal entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
string command = "INSERT INTO " + tableName + " (" +
|
||||
"objektbezeichnung,ref_startschacht_id,ref_endschacht_id," +
|
||||
"dn,material,haltungslaenge, entwaesserung,ref_projekt_id) VALUES " +
|
||||
"(@1,@2,@3,@4,@5,@6,@7,@8) RETURNING haltung_id";
|
||||
using (var cmd = new NpgsqlCommand(command, conn))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("1", entity.Objektbezeichnung);
|
||||
cmd.Parameters.AddWithValue("2", entity.StartSchacht.Id);
|
||||
cmd.Parameters.AddWithValue("3", entity.EndSchacht.Id);
|
||||
cmd.Parameters.AddWithValue("4", entity.DN);
|
||||
cmd.Parameters.AddWithValue("5", entity.Material);
|
||||
cmd.Parameters.AddWithValue("6", entity.Haltungslaenge);
|
||||
cmd.Parameters.AddWithValue("7", (int)entity.Entwaesserung);
|
||||
cmd.Parameters.AddWithValue("8", entity.Projekt.Id);
|
||||
using var reader = await cmd.ExecuteReaderAsync();
|
||||
reader.Read();
|
||||
entity.Id = reader.GetInt32(0);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
public Task<Kanal> Get(int id)
|
||||
@@ -47,8 +66,11 @@ namespace SewerStammGen.DAL.Services.PostgresqlData
|
||||
{
|
||||
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();
|
||||
int startSchachtID = reader.GetInt32(2);
|
||||
int endSchachtID = reader.GetInt32(3);
|
||||
|
||||
adding.StartSchacht = schaechte.Where(x => x.Id == startSchachtID).Last();
|
||||
adding.EndSchacht = schaechte.Where(x => x.Id == endSchachtID).Last();
|
||||
result.Add(adding);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Npgsql;
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Domain;
|
||||
using SewerStammGen.Shared.Enum;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
Reference in New Issue
Block a user