Daten können hinzugefügt
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,3 +2,6 @@
|
|||||||
/KanSan/bin/Debug/*
|
/KanSan/bin/Debug/*
|
||||||
/KanSan/obj/Debug/*
|
/KanSan/obj/Debug/*
|
||||||
/KanSan/obj/*
|
/KanSan/obj/*
|
||||||
|
/KanSan.Base/bin/*
|
||||||
|
/KanSan.Base/kansan.db
|
||||||
|
/KanSan.Base/obj/*
|
||||||
|
|||||||
80
KanSan.Base/BaseRepository.cs
Normal file
80
KanSan.Base/BaseRepository.cs
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
using KanSan.Base.Interfaces;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace KanSan.Base
|
||||||
|
{
|
||||||
|
public class BaseRepository<TEntity> : IRepository<TEntity> where TEntity : class
|
||||||
|
{
|
||||||
|
internal KanSanContext context;
|
||||||
|
internal DbSet<TEntity> dbSet;
|
||||||
|
|
||||||
|
public BaseRepository(KanSanContext context)
|
||||||
|
{
|
||||||
|
this.context = context;
|
||||||
|
if (context == null) throw new ArgumentNullException("context");
|
||||||
|
this.dbSet = context.Set<TEntity>();
|
||||||
|
}
|
||||||
|
public virtual void Delete(TEntity entityToDelete)
|
||||||
|
{
|
||||||
|
if (context.Entry(entityToDelete).State == EntityState.Detached)
|
||||||
|
dbSet.Attach(entityToDelete);
|
||||||
|
dbSet.Remove(entityToDelete);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete(object id)
|
||||||
|
{
|
||||||
|
TEntity entityToDelete = dbSet.Find(id);
|
||||||
|
Delete(entityToDelete);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<TEntity> Get(Expression<Func<TEntity, bool>> filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, string includeProperties = "")
|
||||||
|
{
|
||||||
|
IQueryable<TEntity> query = dbSet;
|
||||||
|
|
||||||
|
if (filter != null)
|
||||||
|
{
|
||||||
|
query = query.Where(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (includeProperties != null)
|
||||||
|
{
|
||||||
|
foreach (var includeProperty in includeProperties.Split
|
||||||
|
(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
||||||
|
{
|
||||||
|
query = query.Include(includeProperty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (orderBy != null)
|
||||||
|
{
|
||||||
|
return orderBy(query).ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return query.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TEntity GetByID(object id)
|
||||||
|
{
|
||||||
|
return dbSet.Find(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Insert(TEntity entity)
|
||||||
|
{
|
||||||
|
dbSet.Add(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(TEntity entityToUpdate)
|
||||||
|
{
|
||||||
|
dbSet.Attach(entityToUpdate);
|
||||||
|
context.Entry(entityToUpdate).State = EntityState.Modified;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
KanSan.Base/Interfaces/IRepository.cs
Normal file
21
KanSan.Base/Interfaces/IRepository.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace KanSan.Base.Interfaces
|
||||||
|
{
|
||||||
|
public interface IRepository<TEntity> where TEntity: class
|
||||||
|
{
|
||||||
|
void Delete(TEntity entityToDelete);
|
||||||
|
void Delete(object id);
|
||||||
|
IEnumerable<TEntity> Get(
|
||||||
|
Expression<Func<TEntity, bool>> filter = null,
|
||||||
|
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null,
|
||||||
|
string includeProperties = "");
|
||||||
|
TEntity GetByID(object id);
|
||||||
|
void Insert(TEntity entity);
|
||||||
|
void Update(TEntity entityToUpdate);
|
||||||
|
}
|
||||||
|
}
|
||||||
14
KanSan.Base/Interfaces/IUnitOfWork.cs
Normal file
14
KanSan.Base/Interfaces/IUnitOfWork.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using KanSan.Base.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace KanSan.Base.Interfaces
|
||||||
|
{
|
||||||
|
public interface IUnitOfWork
|
||||||
|
{
|
||||||
|
IRepository<Baustelle> BaustellenRepository { get; }
|
||||||
|
IRepository<Kunde> KundenRepository { get; }
|
||||||
|
void Commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
28
KanSan.Base/KanSan.Base.csproj
Normal file
28
KanSan.Base/KanSan.Base.csproj
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.1">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.1" />
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.1.2" />
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="kansan.db">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
16
KanSan.Base/KanSanContext.cs
Normal file
16
KanSan.Base/KanSanContext.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using KanSan.Base.Models;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace KanSan.Base
|
||||||
|
{
|
||||||
|
public class KanSanContext : DbContext
|
||||||
|
{
|
||||||
|
public DbSet<Baustelle> Baustellen { get; set; }
|
||||||
|
public DbSet<Kunde> Kunden { get; set; }
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
{
|
||||||
|
optionsBuilder.UseSqlite("Data Source=kansan.db");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
87
KanSan.Base/Migrations/20200220200339_InitialCommit.Designer.cs
generated
Normal file
87
KanSan.Base/Migrations/20200220200339_InitialCommit.Designer.cs
generated
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using KanSan.Base;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
namespace KanSan.Base.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(KanSanContext))]
|
||||||
|
[Migration("20200220200339_InitialCommit")]
|
||||||
|
partial class InitialCommit
|
||||||
|
{
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "3.1.1");
|
||||||
|
|
||||||
|
modelBuilder.Entity("KanSan.Base.Models.Baustelle", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("GuidNr")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("KundeID")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Ort")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Projektnummer")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Strasse")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.HasIndex("KundeID");
|
||||||
|
|
||||||
|
b.ToTable("Baustellen");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("KanSan.Base.Models.Kunde", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("GuidNr")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Nachname")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Ort")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("PLZ")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Strasse")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Vorname")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Kunden");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("KanSan.Base.Models.Baustelle", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("KanSan.Base.Models.Kunde", "Kunde")
|
||||||
|
.WithMany("Baustellen")
|
||||||
|
.HasForeignKey("KundeID");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
66
KanSan.Base/Migrations/20200220200339_InitialCommit.cs
Normal file
66
KanSan.Base/Migrations/20200220200339_InitialCommit.cs
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace KanSan.Base.Migrations
|
||||||
|
{
|
||||||
|
public partial class InitialCommit : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Kunden",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
ID = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
GuidNr = table.Column<Guid>(nullable: false),
|
||||||
|
Vorname = table.Column<string>(nullable: true),
|
||||||
|
Nachname = table.Column<string>(nullable: true),
|
||||||
|
Strasse = table.Column<string>(nullable: true),
|
||||||
|
PLZ = table.Column<string>(nullable: true),
|
||||||
|
Ort = table.Column<string>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Kunden", x => x.ID);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Baustellen",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
ID = table.Column<int>(nullable: false)
|
||||||
|
.Annotation("Sqlite:Autoincrement", true),
|
||||||
|
GuidNr = table.Column<Guid>(nullable: false),
|
||||||
|
KundeID = table.Column<int>(nullable: true),
|
||||||
|
Ort = table.Column<string>(nullable: true),
|
||||||
|
Strasse = table.Column<string>(nullable: true),
|
||||||
|
Projektnummer = table.Column<string>(nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Baustellen", x => x.ID);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Baustellen_Kunden_KundeID",
|
||||||
|
column: x => x.KundeID,
|
||||||
|
principalTable: "Kunden",
|
||||||
|
principalColumn: "ID",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Baustellen_KundeID",
|
||||||
|
table: "Baustellen",
|
||||||
|
column: "KundeID");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Baustellen");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Kunden");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
85
KanSan.Base/Migrations/KanSanContextModelSnapshot.cs
Normal file
85
KanSan.Base/Migrations/KanSanContextModelSnapshot.cs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using KanSan.Base;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
namespace KanSan.Base.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(KanSanContext))]
|
||||||
|
partial class KanSanContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "3.1.1");
|
||||||
|
|
||||||
|
modelBuilder.Entity("KanSan.Base.Models.Baustelle", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("GuidNr")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<int?>("KundeID")
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<string>("Ort")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Projektnummer")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Strasse")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.HasIndex("KundeID");
|
||||||
|
|
||||||
|
b.ToTable("Baustellen");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("KanSan.Base.Models.Kunde", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("ID")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("INTEGER");
|
||||||
|
|
||||||
|
b.Property<Guid>("GuidNr")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Nachname")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Ort")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("PLZ")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Strasse")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.Property<string>("Vorname")
|
||||||
|
.HasColumnType("TEXT");
|
||||||
|
|
||||||
|
b.HasKey("ID");
|
||||||
|
|
||||||
|
b.ToTable("Kunden");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("KanSan.Base.Models.Baustelle", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("KanSan.Base.Models.Kunde", "Kunde")
|
||||||
|
.WithMany("Baustellen")
|
||||||
|
.HasForeignKey("KundeID");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
14
KanSan.Base/Models/Baustelle.cs
Normal file
14
KanSan.Base/Models/Baustelle.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace KanSan.Base.Models
|
||||||
|
{
|
||||||
|
public class Baustelle : DatenbankClass
|
||||||
|
{
|
||||||
|
public Kunde Kunde { get; set; }
|
||||||
|
public string Ort { get; set; }
|
||||||
|
public string Strasse { get; set; }
|
||||||
|
public string Projektnummer { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
12
KanSan.Base/Models/DatenbankClass.cs
Normal file
12
KanSan.Base/Models/DatenbankClass.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace KanSan.Base.Models
|
||||||
|
{
|
||||||
|
public class DatenbankClass
|
||||||
|
{
|
||||||
|
public int ID { get; set; }
|
||||||
|
public Guid GuidNr { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
17
KanSan.Base/Models/Kunde.cs
Normal file
17
KanSan.Base/Models/Kunde.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace KanSan.Base.Models
|
||||||
|
{
|
||||||
|
public class Kunde : DatenbankClass
|
||||||
|
{
|
||||||
|
public string Vorname { get; set; }
|
||||||
|
public string Nachname { get; set; }
|
||||||
|
public string Strasse { get; set; }
|
||||||
|
public string PLZ { get; set; }
|
||||||
|
public string Ort { get; set; }
|
||||||
|
public List<Baustelle> Baustellen { get; } = new List<Baustelle>();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
41
KanSan.Base/UnitOfWork.cs
Normal file
41
KanSan.Base/UnitOfWork.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using KanSan.Base.Interfaces;
|
||||||
|
using KanSan.Base.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace KanSan.Base
|
||||||
|
{
|
||||||
|
public class UnitOfWork : IUnitOfWork
|
||||||
|
{
|
||||||
|
private KanSanContext _dbContext;
|
||||||
|
private BaseRepository<Baustelle> _baustellen;
|
||||||
|
private BaseRepository<Kunde> _kunden;
|
||||||
|
|
||||||
|
public UnitOfWork(KanSanContext dbContext)
|
||||||
|
{
|
||||||
|
_dbContext = dbContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRepository<Baustelle> BaustellenRepository
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _baustellen ?? (_baustellen = new BaseRepository<Baustelle>(_dbContext));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRepository<Kunde> KundenRepository
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _kunden ?? (_kunden = new BaseRepository<Kunde>(_dbContext));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Commit()
|
||||||
|
{
|
||||||
|
_dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.29728.190
|
VisualStudioVersion = 16.0.29728.190
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KanSan", "KanSan\KanSan.csproj", "{B73CD234-11F8-4FC9-BAC1-AA3DF3D7AB6A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KanSan", "KanSan\KanSan.csproj", "{B73CD234-11F8-4FC9-BAC1-AA3DF3D7AB6A}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KanSan.Base", "KanSan.Base\KanSan.Base.csproj", "{2184A91C-8DFD-45DD-B83F-5D036BADEA52}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -15,6 +17,10 @@ Global
|
|||||||
{B73CD234-11F8-4FC9-BAC1-AA3DF3D7AB6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{B73CD234-11F8-4FC9-BAC1-AA3DF3D7AB6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{B73CD234-11F8-4FC9-BAC1-AA3DF3D7AB6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{B73CD234-11F8-4FC9-BAC1-AA3DF3D7AB6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{B73CD234-11F8-4FC9-BAC1-AA3DF3D7AB6A}.Release|Any CPU.Build.0 = Release|Any CPU
|
{B73CD234-11F8-4FC9-BAC1-AA3DF3D7AB6A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{2184A91C-8DFD-45DD-B83F-5D036BADEA52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2184A91C-8DFD-45DD-B83F-5D036BADEA52}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2184A91C-8DFD-45DD-B83F-5D036BADEA52}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2184A91C-8DFD-45DD-B83F-5D036BADEA52}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -22,9 +22,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="kanSan.db">
|
<ProjectReference Include="..\KanSan.Base\KanSan.Base.csproj" />
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -6,9 +6,23 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="UI\Baustelle\WindowBaustelleEdit.xaml.cs">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Update="UI\Kunde\UCKundeEdit.xaml.cs">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Page Update="MainWindow.xaml">
|
<Page Update="MainWindow.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Update="UI\Baustelle\WindowBaustelleEdit.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
<Page Update="UI\Kunde\UCKundeEdit.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace KanSan.Klassen
|
|
||||||
{
|
|
||||||
public class Baustelle
|
|
||||||
{
|
|
||||||
public Guid ID { get; set; }
|
|
||||||
public Kunde Kunde { get; set; }
|
|
||||||
public string Ort { get; set; }
|
|
||||||
public string Strasse { get; set; }
|
|
||||||
public string Projektnummer { get; set; }
|
|
||||||
|
|
||||||
public Baustelle(Kunde kunde)
|
|
||||||
{
|
|
||||||
Kunde = kunde;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Baustelle()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace KanSan.Klassen
|
|
||||||
{
|
|
||||||
public class Kunde
|
|
||||||
{
|
|
||||||
public Guid ID { get; set; }
|
|
||||||
public string Vorname { get; set; }
|
|
||||||
public string Nachname { get; set; }
|
|
||||||
public string Strasse { get; set; }
|
|
||||||
public string PLZ { get; set; }
|
|
||||||
public string Ort { get; set; }
|
|
||||||
|
|
||||||
public List<Baustelle> Baustellen { get; set; } = new List<Baustelle>();
|
|
||||||
|
|
||||||
public void NeueBaustelle(KanSanContext ksc,string ort, string strasse, string projektnummer)
|
|
||||||
{
|
|
||||||
Baustelle baustelle = new Baustelle(this)
|
|
||||||
{
|
|
||||||
Ort = ort,
|
|
||||||
ID = Guid.NewGuid(),
|
|
||||||
Projektnummer = projektnummer,
|
|
||||||
Strasse = strasse
|
|
||||||
};
|
|
||||||
//Baustellen.Add(baustelle);
|
|
||||||
ksc.Add(baustelle);
|
|
||||||
ksc.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
namespace KanSan.Klassen
|
|
||||||
{
|
|
||||||
public class Leistungsverzeichnis
|
|
||||||
{
|
|
||||||
public Guid ID { get; set; }
|
|
||||||
public string Beschreibung { get; set; }
|
|
||||||
public List<LeistungsverzeichnisPosition> Positionen { get; set; }
|
|
||||||
public Leistungsverzeichnis(string beschreibung)
|
|
||||||
{
|
|
||||||
ID = Guid.NewGuid();
|
|
||||||
Beschreibung = beschreibung;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddLeistungsverzeichnisPosition(string Positionnummer,string PositionsBeschreibung,string PositionEinheit, decimal PositionEinheitpreis)
|
|
||||||
{
|
|
||||||
if (Positionen == null) Positionen = new List<LeistungsverzeichnisPosition>();
|
|
||||||
LeistungsverzeichnisPosition pos = new LeistungsverzeichnisPosition();
|
|
||||||
pos.ID = Guid.NewGuid();
|
|
||||||
pos.ref_leistungsverzeichnis = this;
|
|
||||||
pos.Position = Positionnummer;
|
|
||||||
pos.PositionBeschreibung = PositionsBeschreibung;
|
|
||||||
pos.PositionEinheit = PositionEinheit;
|
|
||||||
pos.PositionEinheitspreis = PositionEinheitpreis;
|
|
||||||
|
|
||||||
Positionen.Add(pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class LeistungsverzeichnisPosition
|
|
||||||
{
|
|
||||||
public Guid ID { get; set; }
|
|
||||||
public Leistungsverzeichnis ref_leistungsverzeichnis { get; set; }
|
|
||||||
public string Position { get; set; }
|
|
||||||
public string PositionBeschreibung { get; set; }
|
|
||||||
public string PositionEinheit { get; set; }
|
|
||||||
public decimal PositionEinheitspreis { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
namespace KanSan.Klassen
|
|
||||||
{
|
|
||||||
public class LeistungsverzeichnisBaustelle
|
|
||||||
{
|
|
||||||
public int LeistungsverzeichnisBaustelleID { get; set; }
|
|
||||||
public Baustelle Baustelle { get; set; }
|
|
||||||
public Leistungsverzeichnis Leistungsverzeichniss { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,9 +8,6 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="MainWindow" Height="450" Width="800">
|
Title="MainWindow" Height="450" Width="800">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
<ContentControl Name="ContentController" Content="ContentControl" HorizontalAlignment="Left" Height="402" Margin="226,22,0,0" VerticalAlignment="Top" Width="564"/>
|
||||||
<syncfusion:GridControl HorizontalAlignment="Left" Height="100" Margin="252,147,0,0" VerticalAlignment="Top" Width="469"/>
|
|
||||||
<Button Content="Button" HorizontalAlignment="Left" Height="30" Margin="153,217,0,0" VerticalAlignment="Top" Width="31" Click="Button_Click"/>
|
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using KanSan.Klassen;
|
using KanSan.Base;
|
||||||
|
using KanSan.Base.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace KanSan
|
namespace KanSan
|
||||||
@@ -26,97 +27,14 @@ namespace KanSan
|
|||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
UnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||||
|
var d = unitOfWork.KundenRepository.Get().First();
|
||||||
|
|
||||||
|
UI.UCKundeEdit uCKundeEdit = new UI.UCKundeEdit(d);
|
||||||
|
ContentController.Content = uCKundeEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void InsertOrUpdateGraph(KanSanContext context, Kunde kunde)
|
|
||||||
{
|
|
||||||
var existingKunde = context.Kunden
|
|
||||||
.Include(b => b.Baustellen)
|
|
||||||
.FirstOrDefault(b => b.ID == kunde.ID);
|
|
||||||
|
|
||||||
if (existingKunde == null)
|
|
||||||
context.Add(kunde);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
context.Entry(existingKunde).CurrentValues.SetValues(kunde);
|
|
||||||
foreach(var baustelle in kunde.Baustellen)
|
|
||||||
{
|
|
||||||
var existingBaustelle = existingKunde.Baustellen
|
|
||||||
.FirstOrDefault(p => p.ID == baustelle.ID);
|
|
||||||
if(existingBaustelle == null)
|
|
||||||
{
|
|
||||||
existingKunde.Baustellen.Add(baustelle);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
context.Entry(existingBaustelle).CurrentValues.SetValues(baustelle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
context.SaveChanges();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_Click(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
using (KanSanContext ksc = new KanSanContext())
|
|
||||||
{
|
|
||||||
var kunden = ksc.Kunden.First();
|
|
||||||
kunden.NeueBaustelle(ksc,"Oldenburg", "Strasse33", "20-850-012");
|
|
||||||
/*
|
|
||||||
Baustelle baustelle = new Baustelle(kunden);
|
|
||||||
baustelle.ID = Guid.NewGuid();
|
|
||||||
baustelle.Ort = "Oldenburg";
|
|
||||||
baustelle.Projektnummer = "20-850-006";
|
|
||||||
baustelle.Strasse = "Ammerländer";
|
|
||||||
ksc.Add(baustelle);
|
|
||||||
*/
|
|
||||||
//NeueBaustelle("Oldenburg", "Ammerländer", "20-850-006");
|
|
||||||
|
|
||||||
|
|
||||||
//InsertOrUpdateGraph(ksc, kunden);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*InitialKundenDatabase();
|
|
||||||
InitialLeistungsverzeichnis();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
private void InitialKundenDatabase()
|
|
||||||
{
|
|
||||||
Kunde kunde = new Kunde()
|
|
||||||
{
|
|
||||||
Vorname = "Fa.",
|
|
||||||
Nachname = "OOWV",
|
|
||||||
Ort = "Brake",
|
|
||||||
PLZ = "268741",
|
|
||||||
Strasse = "Donnerschweerstraße 74"
|
|
||||||
};
|
|
||||||
|
|
||||||
//kunde.NeueBaustelle("Oldenburg", "Kaspersweg", "20-850-003");
|
|
||||||
using (KanSanContext ksc = new KanSanContext())
|
|
||||||
{
|
|
||||||
ksc.Kunden.Add(kunde);
|
|
||||||
ksc.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void InitialLeistungsverzeichnis()
|
|
||||||
{
|
|
||||||
using (KanSanContext ksc = new KanSanContext())
|
|
||||||
{
|
|
||||||
|
|
||||||
Leistungsverzeichnis leistungsverzeichnis = new Leistungsverzeichnis("JunkerMevesGenerell");
|
|
||||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.01", "Kurzliner", "Stk", 0);
|
|
||||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.02", "Mat KL", "m", 0);
|
|
||||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.03", "Stutzen Hut", "Stk", 0);
|
|
||||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.04", "Stutzen andere", "Stk", 0);
|
|
||||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.05", "VA-Manschette", "Stk", 0);
|
|
||||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.06", "Öffnen", "Stk", 0);
|
|
||||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.07", "Fräsen", "h", 0);
|
|
||||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.08", "Hindernisse", "Stk", 0);
|
|
||||||
leistungsverzeichnis.AddLeistungsverzeichnisPosition("0.09", "Anrauhen", "Stk", 0);
|
|
||||||
|
|
||||||
ksc.Leistungsverzeichnisses.Add(leistungsverzeichnis);
|
|
||||||
ksc.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,166 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using KanSan;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
namespace KanSan.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(KanSanContext))]
|
|
||||||
[Migration("20200216122731_InitialCommit")]
|
|
||||||
partial class InitialCommit
|
|
||||||
{
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
|
|
||||||
.HasAnnotation("ProductVersion", "3.1.1")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.Baustelle", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("ID")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid?>("KundeID")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Ort")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Projektnummer")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Strasse")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("ID");
|
|
||||||
|
|
||||||
b.HasIndex("KundeID");
|
|
||||||
|
|
||||||
b.ToTable("Baustellen");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.Kunde", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("ID")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Nachname")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Ort")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("PLZ")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Strasse")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Vorname")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("ID");
|
|
||||||
|
|
||||||
b.ToTable("Kunden");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.Leistungsverzeichnis", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("ID")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Beschreibung")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("ID");
|
|
||||||
|
|
||||||
b.ToTable("Leistungsverzeichnisses");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisBaustelle", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("LeistungsverzeichnisBaustelleID")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<Guid?>("BaustelleID")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid?>("LeistungsverzeichnissID")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("LeistungsverzeichnisBaustelleID");
|
|
||||||
|
|
||||||
b.HasIndex("BaustelleID");
|
|
||||||
|
|
||||||
b.HasIndex("LeistungsverzeichnissID");
|
|
||||||
|
|
||||||
b.ToTable("LeistungsverzeichnisBaustelle");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisPosition", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("ID")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Position")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("PositionBeschreibung")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("PositionEinheit")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<decimal>("PositionEinheitspreis")
|
|
||||||
.HasColumnType("numeric");
|
|
||||||
|
|
||||||
b.Property<Guid?>("ref_leistungsverzeichnisID")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("ID");
|
|
||||||
|
|
||||||
b.HasIndex("ref_leistungsverzeichnisID");
|
|
||||||
|
|
||||||
b.ToTable("LeistungsverzeichnisPosition");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.Baustelle", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("KanSan.Klassen.Kunde", null)
|
|
||||||
.WithMany("Baustellen")
|
|
||||||
.HasForeignKey("KundeID");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisBaustelle", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("KanSan.Klassen.Baustelle", "Baustelle")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("BaustelleID");
|
|
||||||
|
|
||||||
b.HasOne("KanSan.Klassen.Leistungsverzeichnis", "Leistungsverzeichniss")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("LeistungsverzeichnissID");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisPosition", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("KanSan.Klassen.Leistungsverzeichnis", "ref_leistungsverzeichnis")
|
|
||||||
.WithMany("Positionen")
|
|
||||||
.HasForeignKey("ref_leistungsverzeichnisID");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
namespace KanSan.Migrations
|
|
||||||
{
|
|
||||||
public partial class InitialCommit : Migration
|
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Kunden",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<Guid>(nullable: false),
|
|
||||||
Vorname = table.Column<string>(nullable: true),
|
|
||||||
Nachname = table.Column<string>(nullable: true),
|
|
||||||
Strasse = table.Column<string>(nullable: true),
|
|
||||||
PLZ = table.Column<string>(nullable: true),
|
|
||||||
Ort = table.Column<string>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Kunden", x => x.ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Leistungsverzeichnisses",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<Guid>(nullable: false),
|
|
||||||
Beschreibung = table.Column<string>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Leistungsverzeichnisses", x => x.ID);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Baustellen",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<Guid>(nullable: false),
|
|
||||||
Ort = table.Column<string>(nullable: true),
|
|
||||||
Strasse = table.Column<string>(nullable: true),
|
|
||||||
Projektnummer = table.Column<string>(nullable: true),
|
|
||||||
KundeID = table.Column<Guid>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Baustellen", x => x.ID);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Baustellen_Kunden_KundeID",
|
|
||||||
column: x => x.KundeID,
|
|
||||||
principalTable: "Kunden",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "LeistungsverzeichnisPosition",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
ID = table.Column<Guid>(nullable: false),
|
|
||||||
ref_leistungsverzeichnisID = table.Column<Guid>(nullable: true),
|
|
||||||
Position = table.Column<string>(nullable: true),
|
|
||||||
PositionBeschreibung = table.Column<string>(nullable: true),
|
|
||||||
PositionEinheit = table.Column<string>(nullable: true),
|
|
||||||
PositionEinheitspreis = table.Column<decimal>(nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_LeistungsverzeichnisPosition", x => x.ID);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_LeistungsverzeichnisPosition_Leistungsverzeichnisses_ref_le~",
|
|
||||||
column: x => x.ref_leistungsverzeichnisID,
|
|
||||||
principalTable: "Leistungsverzeichnisses",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "LeistungsverzeichnisBaustelle",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
LeistungsverzeichnisBaustelleID = table.Column<int>(nullable: false)
|
|
||||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
||||||
BaustelleID = table.Column<Guid>(nullable: true),
|
|
||||||
LeistungsverzeichnissID = table.Column<Guid>(nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_LeistungsverzeichnisBaustelle", x => x.LeistungsverzeichnisBaustelleID);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_LeistungsverzeichnisBaustelle_Baustellen_BaustelleID",
|
|
||||||
column: x => x.BaustelleID,
|
|
||||||
principalTable: "Baustellen",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_LeistungsverzeichnisBaustelle_Leistungsverzeichnisses_Leist~",
|
|
||||||
column: x => x.LeistungsverzeichnissID,
|
|
||||||
principalTable: "Leistungsverzeichnisses",
|
|
||||||
principalColumn: "ID",
|
|
||||||
onDelete: ReferentialAction.Restrict);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Baustellen_KundeID",
|
|
||||||
table: "Baustellen",
|
|
||||||
column: "KundeID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_LeistungsverzeichnisBaustelle_BaustelleID",
|
|
||||||
table: "LeistungsverzeichnisBaustelle",
|
|
||||||
column: "BaustelleID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_LeistungsverzeichnisBaustelle_LeistungsverzeichnissID",
|
|
||||||
table: "LeistungsverzeichnisBaustelle",
|
|
||||||
column: "LeistungsverzeichnissID");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_LeistungsverzeichnisPosition_ref_leistungsverzeichnisID",
|
|
||||||
table: "LeistungsverzeichnisPosition",
|
|
||||||
column: "ref_leistungsverzeichnisID");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "LeistungsverzeichnisBaustelle");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "LeistungsverzeichnisPosition");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Baustellen");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Leistungsverzeichnisses");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Kunden");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,164 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using KanSan;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
||||||
|
|
||||||
namespace KanSan.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(KanSanContext))]
|
|
||||||
partial class KanSanContextModelSnapshot : ModelSnapshot
|
|
||||||
{
|
|
||||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
|
|
||||||
.HasAnnotation("ProductVersion", "3.1.1")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.Baustelle", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("ID")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid?>("KundeID")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Ort")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Projektnummer")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Strasse")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("ID");
|
|
||||||
|
|
||||||
b.HasIndex("KundeID");
|
|
||||||
|
|
||||||
b.ToTable("Baustellen");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.Kunde", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("ID")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Nachname")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Ort")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("PLZ")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Strasse")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("Vorname")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("ID");
|
|
||||||
|
|
||||||
b.ToTable("Kunden");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.Leistungsverzeichnis", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("ID")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Beschreibung")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.HasKey("ID");
|
|
||||||
|
|
||||||
b.ToTable("Leistungsverzeichnisses");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisBaustelle", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("LeistungsverzeichnisBaustelleID")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
|
||||||
|
|
||||||
b.Property<Guid?>("BaustelleID")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<Guid?>("LeistungsverzeichnissID")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("LeistungsverzeichnisBaustelleID");
|
|
||||||
|
|
||||||
b.HasIndex("BaustelleID");
|
|
||||||
|
|
||||||
b.HasIndex("LeistungsverzeichnissID");
|
|
||||||
|
|
||||||
b.ToTable("LeistungsverzeichnisBaustelle");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisPosition", b =>
|
|
||||||
{
|
|
||||||
b.Property<Guid>("ID")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.Property<string>("Position")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("PositionBeschreibung")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("PositionEinheit")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<decimal>("PositionEinheitspreis")
|
|
||||||
.HasColumnType("numeric");
|
|
||||||
|
|
||||||
b.Property<Guid?>("ref_leistungsverzeichnisID")
|
|
||||||
.HasColumnType("uuid");
|
|
||||||
|
|
||||||
b.HasKey("ID");
|
|
||||||
|
|
||||||
b.HasIndex("ref_leistungsverzeichnisID");
|
|
||||||
|
|
||||||
b.ToTable("LeistungsverzeichnisPosition");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.Baustelle", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("KanSan.Klassen.Kunde", null)
|
|
||||||
.WithMany("Baustellen")
|
|
||||||
.HasForeignKey("KundeID");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisBaustelle", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("KanSan.Klassen.Baustelle", "Baustelle")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("BaustelleID");
|
|
||||||
|
|
||||||
b.HasOne("KanSan.Klassen.Leistungsverzeichnis", "Leistungsverzeichniss")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("LeistungsverzeichnissID");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("KanSan.Klassen.LeistungsverzeichnisPosition", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("KanSan.Klassen.Leistungsverzeichnis", "ref_leistungsverzeichnis")
|
|
||||||
.WithMany("Positionen")
|
|
||||||
.HasForeignKey("ref_leistungsverzeichnisID");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using KanSan.Klassen;
|
|
||||||
|
|
||||||
namespace KanSan
|
|
||||||
{
|
|
||||||
public class KanSanContext : DbContext
|
|
||||||
{
|
|
||||||
|
|
||||||
public DbSet<Kunde> Kunden { get; set; }
|
|
||||||
public DbSet<Leistungsverzeichnis> Leistungsverzeichnisses { get; set; }
|
|
||||||
public DbSet<LeistungsverzeichnisBaustelle> LeistungsverzeichnisBaustelle { get; set; }
|
|
||||||
public DbSet<LeistungsverzeichnisPosition> LeistungsverzeichnisPosition { get; set; }
|
|
||||||
public DbSet<Baustelle> Baustellen { get; set; }
|
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
|
||||||
{
|
|
||||||
//options.UseSqlite("Data Source=kanSan.db");
|
|
||||||
options.UseNpgsql("Host=localhost;Database=kanSan;Username=kansan;Password=kansan");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
modelBuilder.Entity<LeistungsverzeichnisBaustelle>(eb =>
|
|
||||||
{
|
|
||||||
eb.HasNoKey();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
25
KanSan/UI/Baustelle/WindowBaustelleEdit.xaml
Normal file
25
KanSan/UI/Baustelle/WindowBaustelleEdit.xaml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<Window x:Class="KanSan.UI.WindowBaustelleEdit"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:KanSan.UI"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="FRMBaustelle" Height="450" Width="800" Closed="Window_Closed">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="80" />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label>Ort</Label>
|
||||||
|
<Label Grid.Row="1">Strasse</Label>
|
||||||
|
|
||||||
|
<TextBox Grid.Column="1" Name="Ort" Text="{Binding Ort}"/>
|
||||||
|
<TextBox Grid.Column="1" Name="Strasse" Grid.Row="1" Text="{Binding Strasse}" />
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
62
KanSan/UI/Baustelle/WindowBaustelleEdit.xaml.cs
Normal file
62
KanSan/UI/Baustelle/WindowBaustelleEdit.xaml.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
using KanSan.Base;
|
||||||
|
using KanSan.Base.Models;
|
||||||
|
using KanSan.ViewModel;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace KanSan.UI
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaktionslogik für FRMBaustelle.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class WindowBaustelleEdit : Window
|
||||||
|
{
|
||||||
|
private UnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||||
|
private Baustelle bs = null;
|
||||||
|
|
||||||
|
|
||||||
|
public WindowBaustelleEdit(Baustelle baustelle)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
if (baustelle == null) throw new ArgumentNullException("baustelle");
|
||||||
|
|
||||||
|
bs = baustelle;
|
||||||
|
|
||||||
|
BaustelleViewModel model = new BaustelleViewModel(bs);
|
||||||
|
|
||||||
|
|
||||||
|
model.PropertyChanged += Model_PropertyChanged;
|
||||||
|
|
||||||
|
this.DataContext = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Model_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
BaustelleViewModel baustelleViewModel = (BaustelleViewModel)sender;
|
||||||
|
bs.Ort = baustelleViewModel.Ort;
|
||||||
|
bs.Projektnummer = baustelleViewModel.Projektnummer;
|
||||||
|
bs.Strasse = baustelleViewModel.Strasse;
|
||||||
|
|
||||||
|
unitOfWork.BaustellenRepository.Update(bs);
|
||||||
|
//Debugger.Break();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Window_Closed(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
unitOfWork.Commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
KanSan/UI/Kunde/UCKundeEdit.xaml
Normal file
34
KanSan/UI/Kunde/UCKundeEdit.xaml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<UserControl x:Class="KanSan.UI.UCKundeEdit"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:KanSan.UI"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition />
|
||||||
|
<ColumnDefinition />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<Label Grid.Column="0" Grid.Row="0">Vorname</Label>
|
||||||
|
<Label Grid.Column="0" Grid.Row="1">Nachname</Label>
|
||||||
|
<Label Grid.Column="0" Grid.Row="2">Strasse</Label>
|
||||||
|
<Label Grid.Column="0" Grid.Row="3">Plz</Label>
|
||||||
|
<Label Grid.Column="0" Grid.Row="4">Ort</Label>
|
||||||
|
|
||||||
|
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Vorname}" />
|
||||||
|
<TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Nachname}" />
|
||||||
|
<TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Strasse}" />
|
||||||
|
<TextBox Grid.Column="1" Grid.Row="3" Text="{Binding PLZ}" />
|
||||||
|
<TextBox Grid.Column="1" Grid.Row="4" Text="{Binding Ort}" />
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
44
KanSan/UI/Kunde/UCKundeEdit.xaml.cs
Normal file
44
KanSan/UI/Kunde/UCKundeEdit.xaml.cs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
using KanSan.Base;
|
||||||
|
using KanSan.Base.Models;
|
||||||
|
using KanSan.ViewModel;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace KanSan.UI
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaktionslogik für UCKundeEdit.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class UCKundeEdit : UserControl
|
||||||
|
{
|
||||||
|
private Kunde kunde = null;
|
||||||
|
private UnitOfWork unitOfWork = null;
|
||||||
|
public UCKundeEdit(Kunde kunde)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
this.kunde = kunde;
|
||||||
|
|
||||||
|
unitOfWork = new UnitOfWork(new KanSanContext());
|
||||||
|
|
||||||
|
KundeViewModel kundeViewModel = new KundeViewModel(kunde);
|
||||||
|
kundeViewModel.PropertyChanged += KundeViewModel_PropertyChanged;
|
||||||
|
this.DataContext = kundeViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void KundeViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
68
KanSan/ViewModel/BaustelleViewModel.cs
Normal file
68
KanSan/ViewModel/BaustelleViewModel.cs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
using KanSan.Base.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace KanSan.ViewModel
|
||||||
|
{
|
||||||
|
class BaustelleViewModel : PropertyChangedClass,INotifyPropertyChanged
|
||||||
|
{
|
||||||
|
private Baustelle _baustelle;
|
||||||
|
|
||||||
|
|
||||||
|
private string ort;
|
||||||
|
private string strasse;
|
||||||
|
private string projektnummer;
|
||||||
|
public string Ort
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ort;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (ort == value) return;
|
||||||
|
ort = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string Strasse
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return strasse;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (strasse == value) return;
|
||||||
|
strasse = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string Projektnummer
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return projektnummer;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (projektnummer == value) return;
|
||||||
|
projektnummer = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public BaustelleViewModel(Baustelle baustelle)
|
||||||
|
{
|
||||||
|
_baustelle = baustelle;
|
||||||
|
ort = _baustelle.Ort;
|
||||||
|
strasse = _baustelle.Strasse;
|
||||||
|
projektnummer = _baustelle.Projektnummer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
96
KanSan/ViewModel/KundeViewModel.cs
Normal file
96
KanSan/ViewModel/KundeViewModel.cs
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
using KanSan.Base.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace KanSan.ViewModel
|
||||||
|
{
|
||||||
|
class KundeViewModel : PropertyChangedClass, INotifyPropertyChanged
|
||||||
|
{
|
||||||
|
private Kunde _kunde;
|
||||||
|
private string vorname;
|
||||||
|
private string nachname;
|
||||||
|
private string strasse;
|
||||||
|
private string plz;
|
||||||
|
private string ort;
|
||||||
|
|
||||||
|
#region getters
|
||||||
|
public string Vorname
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return vorname;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (vorname == value) return;
|
||||||
|
vorname = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string Nachname
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return nachname;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (nachname == value) return;
|
||||||
|
nachname = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string Strasse
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return strasse;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (strasse == value) return;
|
||||||
|
strasse = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string PLZ
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return plz;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (plz == value) return;
|
||||||
|
plz = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string Ort
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ort;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (ort == value) return;
|
||||||
|
ort = value;
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public KundeViewModel(Kunde kunde)
|
||||||
|
{
|
||||||
|
_kunde = kunde;
|
||||||
|
vorname = _kunde.Vorname;
|
||||||
|
nachname = _kunde.Nachname;
|
||||||
|
strasse = _kunde.Strasse;
|
||||||
|
plz = _kunde.PLZ;
|
||||||
|
ort = _kunde.Ort;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
18
KanSan/ViewModel/PropertyChangedClass.cs
Normal file
18
KanSan/ViewModel/PropertyChangedClass.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace KanSan.ViewModel
|
||||||
|
{
|
||||||
|
class PropertyChangedClass
|
||||||
|
{
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
protected internal void OnPropertyChanged([CallerMemberName] string propertyname = null)
|
||||||
|
{
|
||||||
|
if (PropertyChanged != null)
|
||||||
|
PropertyChanged(this, new PropertyChangedEventArgs(propertyname));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
KanSan/kanSan.db
BIN
KanSan/kanSan.db
Binary file not shown.
Reference in New Issue
Block a user