Haltungübersicht angefangen

This commit is contained in:
2023-04-03 11:17:29 +02:00
parent d4b38ff7ae
commit 7999b7ffd0
33 changed files with 697 additions and 429 deletions

View File

@@ -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("20230331121831_SchachtRefProjectVirtual")]
partial class SchachtRefProjectVirtual
{
/// <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
}
}
}

View File

@@ -1,22 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace SewerStammGen.EntityFramework.Migrations
{
/// <inheritdoc />
public partial class SchachtRefProjectVirtual : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@@ -50,7 +50,7 @@ namespace SewerStammGen.EntityFramework.Migrations
b.HasKey("Id");
b.ToTable("Auftraggebers");
b.ToTable("Auftraggebers", (string)null);
});
modelBuilder.Entity("Shared.Domain.Kanal", b =>
@@ -93,7 +93,7 @@ namespace SewerStammGen.EntityFramework.Migrations
b.HasIndex("StartSchachtId");
b.ToTable("Kanaele");
b.ToTable("Kanaele", (string)null);
});
modelBuilder.Entity("Shared.Domain.Projekt", b =>
@@ -129,7 +129,7 @@ namespace SewerStammGen.EntityFramework.Migrations
b.HasIndex("AuftraggeberId");
b.ToTable("Projekte");
b.ToTable("Projekte", (string)null);
});
modelBuilder.Entity("Shared.Domain.Schacht", b =>
@@ -165,7 +165,7 @@ namespace SewerStammGen.EntityFramework.Migrations
b.HasIndex("ProjektId");
b.ToTable("Schaechte");
b.ToTable("Schaechte", (string)null);
});
modelBuilder.Entity("Shared.Domain.Kanal", b =>

View File

@@ -0,0 +1,70 @@
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 Task<Kanal> Update(int id, Kanal entity)
{
throw new NotImplementedException();
}
}
}