Objectliste angefangen

This commit is contained in:
HuskyTeufel
2021-09-16 20:36:55 +02:00
parent 4123cc7aba
commit 0f11ce7f0f
26 changed files with 1127 additions and 21 deletions

View File

@@ -23,6 +23,8 @@ namespace DaSaSo.EntityFramework
public DbSet<Client>? Clients { get; set; }
public DbSet<Project>? Projects { get; set; }
public DbSet<Buildingsite>? Buildingsites { get; set; }
public DbSet<SewerObject>? SewerObjects { get; set; }
public DbSet<SewerDamage>? SewerDamages { get; set; }
}
}

View File

@@ -0,0 +1,234 @@
// <auto-generated />
using System;
using DaSaSo.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DaSaSo.EntityFramework.Migrations
{
[DbContext(typeof(DaSaSoDbContext))]
[Migration("20210916075225_SewerDamageAdded")]
partial class SewerDamageAdded
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 63)
.HasAnnotation("ProductVersion", "6.0.0-preview.7.21378.4")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
modelBuilder.Entity("DaSaSo.Domain.Model.Buildingsite", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("BuildingSiteNumber")
.HasColumnType("text");
b.Property<string>("ContactPerson")
.HasColumnType("text");
b.Property<string>("Country")
.HasColumnType("text");
b.Property<int?>("ProjectId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ProjectId");
b.ToTable("Buildingsites");
});
modelBuilder.Entity("DaSaSo.Domain.Model.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Country")
.HasColumnType("text");
b.Property<string>("Firstname")
.HasColumnType("text");
b.Property<string>("LastName")
.HasColumnType("text");
b.Property<string>("Postcode")
.HasColumnType("text");
b.Property<string>("Street")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("DaSaSo.Domain.Model.Project", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int?>("ClientId")
.HasColumnType("integer");
b.Property<string>("Name")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Projects");
});
modelBuilder.Entity("DaSaSo.Domain.Model.SewerDamage", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("DamageType")
.HasColumnType("integer");
b.Property<decimal>("Distance")
.HasColumnType("numeric");
b.Property<int>("PreparationType")
.HasColumnType("integer");
b.Property<int?>("SewerObjectId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SewerObjectId");
b.ToTable("SewerDamages");
});
modelBuilder.Entity("DaSaSo.Domain.Model.SewerObjects", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int?>("BuildingSiteId")
.HasColumnType("integer");
b.Property<bool>("BuildingsiteBarier")
.HasColumnType("boolean");
b.Property<int>("DN")
.HasColumnType("integer");
b.Property<string>("Material")
.HasColumnType("text");
b.Property<string>("ObjektName")
.HasColumnType("text");
b.Property<bool>("PermitNeeded")
.HasColumnType("boolean");
b.Property<string>("PointFrom")
.HasColumnType("text");
b.Property<string>("PointTo")
.HasColumnType("text");
b.Property<bool>("SewerActivated")
.HasColumnType("boolean");
b.Property<bool>("SewerCleaned")
.HasColumnType("boolean");
b.Property<decimal>("SewerLength")
.HasColumnType("numeric");
b.Property<string>("StreetName")
.HasColumnType("text");
b.Property<bool>("WaterBarrier")
.HasColumnType("boolean");
b.HasKey("Id");
b.HasIndex("BuildingSiteId");
b.ToTable("SewerObjects");
});
modelBuilder.Entity("DaSaSo.Domain.Model.Buildingsite", b =>
{
b.HasOne("DaSaSo.Domain.Model.Project", "Project")
.WithMany("BuildingSites")
.HasForeignKey("ProjectId");
b.Navigation("Project");
});
modelBuilder.Entity("DaSaSo.Domain.Model.Project", b =>
{
b.HasOne("DaSaSo.Domain.Model.Client", "Client")
.WithMany("Projects")
.HasForeignKey("ClientId");
b.Navigation("Client");
});
modelBuilder.Entity("DaSaSo.Domain.Model.SewerDamage", b =>
{
b.HasOne("DaSaSo.Domain.Model.SewerObjects", "SewerObject")
.WithMany("SewerDamages")
.HasForeignKey("SewerObjectId");
b.Navigation("SewerObject");
});
modelBuilder.Entity("DaSaSo.Domain.Model.SewerObjects", b =>
{
b.HasOne("DaSaSo.Domain.Model.Buildingsite", "BuildingSite")
.WithMany("SewerObjects")
.HasForeignKey("BuildingSiteId");
b.Navigation("BuildingSite");
});
modelBuilder.Entity("DaSaSo.Domain.Model.Buildingsite", b =>
{
b.Navigation("SewerObjects");
});
modelBuilder.Entity("DaSaSo.Domain.Model.Client", b =>
{
b.Navigation("Projects");
});
modelBuilder.Entity("DaSaSo.Domain.Model.Project", b =>
{
b.Navigation("BuildingSites");
});
modelBuilder.Entity("DaSaSo.Domain.Model.SewerObjects", b =>
{
b.Navigation("SewerDamages");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,109 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DaSaSo.EntityFramework.Migrations
{
public partial class SewerDamageAdded : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "BuildingsiteBarier",
table: "SewerObjects",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "Material",
table: "SewerObjects",
type: "text",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "PermitNeeded",
table: "SewerObjects",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "SewerActivated",
table: "SewerObjects",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "SewerCleaned",
table: "SewerObjects",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "WaterBarrier",
table: "SewerObjects",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.CreateTable(
name: "SewerDamages",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
SewerObjectId = table.Column<int>(type: "integer", nullable: true),
Distance = table.Column<decimal>(type: "numeric", nullable: false),
DamageType = table.Column<int>(type: "integer", nullable: false),
PreparationType = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SewerDamages", x => x.Id);
table.ForeignKey(
name: "FK_SewerDamages_SewerObjects_SewerObjectId",
column: x => x.SewerObjectId,
principalTable: "SewerObjects",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_SewerDamages_SewerObjectId",
table: "SewerDamages",
column: "SewerObjectId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "SewerDamages");
migrationBuilder.DropColumn(
name: "BuildingsiteBarier",
table: "SewerObjects");
migrationBuilder.DropColumn(
name: "Material",
table: "SewerObjects");
migrationBuilder.DropColumn(
name: "PermitNeeded",
table: "SewerObjects");
migrationBuilder.DropColumn(
name: "SewerActivated",
table: "SewerObjects");
migrationBuilder.DropColumn(
name: "SewerCleaned",
table: "SewerObjects");
migrationBuilder.DropColumn(
name: "WaterBarrier",
table: "SewerObjects");
}
}
}

View File

@@ -0,0 +1,234 @@
// <auto-generated />
using System;
using DaSaSo.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DaSaSo.EntityFramework.Migrations
{
[DbContext(typeof(DaSaSoDbContext))]
[Migration("20210916135239_SewerObjectsAdded")]
partial class SewerObjectsAdded
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:MaxIdentifierLength", 63)
.HasAnnotation("ProductVersion", "6.0.0-preview.7.21378.4")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
modelBuilder.Entity("DaSaSo.Domain.Model.Buildingsite", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("BuildingSiteNumber")
.HasColumnType("text");
b.Property<string>("ContactPerson")
.HasColumnType("text");
b.Property<string>("Country")
.HasColumnType("text");
b.Property<int?>("ProjectId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("ProjectId");
b.ToTable("Buildingsites");
});
modelBuilder.Entity("DaSaSo.Domain.Model.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<string>("Country")
.HasColumnType("text");
b.Property<string>("Firstname")
.HasColumnType("text");
b.Property<string>("LastName")
.HasColumnType("text");
b.Property<string>("Postcode")
.HasColumnType("text");
b.Property<string>("Street")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("DaSaSo.Domain.Model.Project", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int?>("ClientId")
.HasColumnType("integer");
b.Property<string>("Name")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Projects");
});
modelBuilder.Entity("DaSaSo.Domain.Model.SewerDamage", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("DamageType")
.HasColumnType("integer");
b.Property<decimal>("Distance")
.HasColumnType("numeric");
b.Property<int>("PreparationType")
.HasColumnType("integer");
b.Property<int?>("SewerObjectId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SewerObjectId");
b.ToTable("SewerDamages");
});
modelBuilder.Entity("DaSaSo.Domain.Model.SewerObject", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int?>("BuildingSiteId")
.HasColumnType("integer");
b.Property<bool>("BuildingsiteBarier")
.HasColumnType("boolean");
b.Property<int>("DN")
.HasColumnType("integer");
b.Property<string>("Material")
.HasColumnType("text");
b.Property<string>("ObjektName")
.HasColumnType("text");
b.Property<bool>("PermitNeeded")
.HasColumnType("boolean");
b.Property<string>("PointFrom")
.HasColumnType("text");
b.Property<string>("PointTo")
.HasColumnType("text");
b.Property<bool>("SewerActivated")
.HasColumnType("boolean");
b.Property<bool>("SewerCleaned")
.HasColumnType("boolean");
b.Property<decimal>("SewerLength")
.HasColumnType("numeric");
b.Property<string>("StreetName")
.HasColumnType("text");
b.Property<bool>("WaterBarrier")
.HasColumnType("boolean");
b.HasKey("Id");
b.HasIndex("BuildingSiteId");
b.ToTable("SewerObjects");
});
modelBuilder.Entity("DaSaSo.Domain.Model.Buildingsite", b =>
{
b.HasOne("DaSaSo.Domain.Model.Project", "Project")
.WithMany("BuildingSites")
.HasForeignKey("ProjectId");
b.Navigation("Project");
});
modelBuilder.Entity("DaSaSo.Domain.Model.Project", b =>
{
b.HasOne("DaSaSo.Domain.Model.Client", "Client")
.WithMany("Projects")
.HasForeignKey("ClientId");
b.Navigation("Client");
});
modelBuilder.Entity("DaSaSo.Domain.Model.SewerDamage", b =>
{
b.HasOne("DaSaSo.Domain.Model.SewerObject", "SewerObject")
.WithMany("SewerDamages")
.HasForeignKey("SewerObjectId");
b.Navigation("SewerObject");
});
modelBuilder.Entity("DaSaSo.Domain.Model.SewerObject", b =>
{
b.HasOne("DaSaSo.Domain.Model.Buildingsite", "BuildingSite")
.WithMany("SewerObjects")
.HasForeignKey("BuildingSiteId");
b.Navigation("BuildingSite");
});
modelBuilder.Entity("DaSaSo.Domain.Model.Buildingsite", b =>
{
b.Navigation("SewerObjects");
});
modelBuilder.Entity("DaSaSo.Domain.Model.Client", b =>
{
b.Navigation("Projects");
});
modelBuilder.Entity("DaSaSo.Domain.Model.Project", b =>
{
b.Navigation("BuildingSites");
});
modelBuilder.Entity("DaSaSo.Domain.Model.SewerObject", b =>
{
b.Navigation("SewerDamages");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace DaSaSo.EntityFramework.Migrations
{
public partial class SewerObjectsAdded : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@@ -92,7 +92,33 @@ namespace DaSaSo.EntityFramework.Migrations
b.ToTable("Projects");
});
modelBuilder.Entity("DaSaSo.Domain.Model.SewerObjects", b =>
modelBuilder.Entity("DaSaSo.Domain.Model.SewerDamage", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property<int>("DamageType")
.HasColumnType("integer");
b.Property<decimal>("Distance")
.HasColumnType("numeric");
b.Property<int>("PreparationType")
.HasColumnType("integer");
b.Property<int?>("SewerObjectId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("SewerObjectId");
b.ToTable("SewerDamages");
});
modelBuilder.Entity("DaSaSo.Domain.Model.SewerObject", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@@ -102,24 +128,42 @@ namespace DaSaSo.EntityFramework.Migrations
b.Property<int?>("BuildingSiteId")
.HasColumnType("integer");
b.Property<bool>("BuildingsiteBarier")
.HasColumnType("boolean");
b.Property<int>("DN")
.HasColumnType("integer");
b.Property<string>("Material")
.HasColumnType("text");
b.Property<string>("ObjektName")
.HasColumnType("text");
b.Property<bool>("PermitNeeded")
.HasColumnType("boolean");
b.Property<string>("PointFrom")
.HasColumnType("text");
b.Property<string>("PointTo")
.HasColumnType("text");
b.Property<bool>("SewerActivated")
.HasColumnType("boolean");
b.Property<bool>("SewerCleaned")
.HasColumnType("boolean");
b.Property<decimal>("SewerLength")
.HasColumnType("numeric");
b.Property<string>("StreetName")
.HasColumnType("text");
b.Property<bool>("WaterBarrier")
.HasColumnType("boolean");
b.HasKey("Id");
b.HasIndex("BuildingSiteId");
@@ -145,7 +189,16 @@ namespace DaSaSo.EntityFramework.Migrations
b.Navigation("Client");
});
modelBuilder.Entity("DaSaSo.Domain.Model.SewerObjects", b =>
modelBuilder.Entity("DaSaSo.Domain.Model.SewerDamage", b =>
{
b.HasOne("DaSaSo.Domain.Model.SewerObject", "SewerObject")
.WithMany("SewerDamages")
.HasForeignKey("SewerObjectId");
b.Navigation("SewerObject");
});
modelBuilder.Entity("DaSaSo.Domain.Model.SewerObject", b =>
{
b.HasOne("DaSaSo.Domain.Model.Buildingsite", "BuildingSite")
.WithMany("SewerObjects")
@@ -168,6 +221,11 @@ namespace DaSaSo.EntityFramework.Migrations
{
b.Navigation("BuildingSites");
});
modelBuilder.Entity("DaSaSo.Domain.Model.SewerObject", b =>
{
b.Navigation("SewerDamages");
});
#pragma warning restore 612, 618
}
}

View File

@@ -0,0 +1,59 @@
using DaSaSo.Domain.Model;
using DaSaSo.Domain.Services;
using DaSaSo.EntityFramework.Services.Common;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DaSaSo.EntityFramework.Services
{
public class SewerObjectDataService : IDataService<SewerObject>
{
private readonly DaSaSoDbContextFactory _contextFactory;
private readonly NonQueryDataService<SewerObject> _nonQueryDataService;
public SewerObjectDataService(DaSaSoDbContextFactory contextFactory)
{
this._contextFactory = contextFactory;
_nonQueryDataService = new NonQueryDataService<SewerObject>(contextFactory);
}
public async Task<SewerObject> Create(SewerObject entity)
{
return await _nonQueryDataService.Create(entity);
}
public async Task<bool> Delete(int id)
{
return await _nonQueryDataService.Delete(id);
}
public Task<SewerObject> Get(int id)
{
throw new NotImplementedException();
}
public Task<IEnumerable<SewerObject>> GetAll()
{
throw new NotImplementedException();
}
public async Task<IEnumerable<SewerObject>> GetAllByBuildingsite(Buildingsite buildingsite)
{
int id = buildingsite.Id;
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
{
IEnumerable<SewerObject> entities = await context.SewerObjects.Where(x => x.BuildingSite.Id == id).ToListAsync();
return entities;
}
}
public async Task<SewerObject> Update(int id, SewerObject entity)
{
return await _nonQueryDataService.Update(id, entity);
}
}
}