diff --git a/SewerStammGen.EntityFramework/Migrations/20230331121831_SchachtRefProjectVirtual.Designer.cs b/SewerStammGen.EntityFramework/Migrations/20230331121831_SchachtRefProjectVirtual.Designer.cs
deleted file mode 100644
index 8e84c7e..0000000
--- a/SewerStammGen.EntityFramework/Migrations/20230331121831_SchachtRefProjectVirtual.Designer.cs
+++ /dev/null
@@ -1,222 +0,0 @@
-//
-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
- {
- ///
- 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("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("Ansprechpartner")
- .HasColumnType("text");
-
- b.Property("Name")
- .HasColumnType("text");
-
- b.Property("Ort")
- .HasColumnType("text");
-
- b.Property("Postleitzahl")
- .HasColumnType("text");
-
- b.Property("Strasse")
- .HasColumnType("text");
-
- b.Property("Telefonnummer")
- .HasColumnType("text");
-
- b.HasKey("Id");
-
- b.ToTable("Auftraggebers");
- });
-
- modelBuilder.Entity("Shared.Domain.Kanal", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("DN")
- .HasColumnType("integer");
-
- b.Property("EndSchachtId")
- .HasColumnType("integer");
-
- b.Property("Entwaesserung")
- .HasColumnType("integer");
-
- b.Property("Haltungslaenge")
- .HasColumnType("numeric");
-
- b.Property("Material")
- .HasColumnType("text");
-
- b.Property("Objektbezeichnung")
- .HasColumnType("text");
-
- b.Property("ProjektId")
- .HasColumnType("integer");
-
- b.Property("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("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("AuftraggeberId")
- .HasColumnType("integer");
-
- b.Property("Erstelldatum")
- .HasColumnType("text");
-
- b.Property("ExportType")
- .HasColumnType("integer");
-
- b.Property("Kodierungssystem")
- .HasColumnType("integer");
-
- b.Property("Ort")
- .HasColumnType("text");
-
- b.Property("Projektname")
- .HasColumnType("text");
-
- b.Property("Strasse")
- .HasColumnType("text");
-
- b.HasKey("Id");
-
- b.HasIndex("AuftraggeberId");
-
- b.ToTable("Projekte");
- });
-
- modelBuilder.Entity("Shared.Domain.Schacht", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("integer");
-
- NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
-
- b.Property("DeckelHoehe")
- .HasColumnType("decimal(18,4)");
-
- b.Property("Entwaesserung")
- .HasColumnType("integer");
-
- b.Property("HochWert")
- .HasColumnType("decimal(18,4)");
-
- b.Property("Objektbezeichnung")
- .HasColumnType("text");
-
- b.Property("ProjektId")
- .HasColumnType("integer");
-
- b.Property("RechtsWert")
- .HasColumnType("decimal(18,4)");
-
- b.Property("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
- }
- }
-}
diff --git a/SewerStammGen.EntityFramework/Migrations/20230331121831_SchachtRefProjectVirtual.cs b/SewerStammGen.EntityFramework/Migrations/20230331121831_SchachtRefProjectVirtual.cs
deleted file mode 100644
index 8f56abf..0000000
--- a/SewerStammGen.EntityFramework/Migrations/20230331121831_SchachtRefProjectVirtual.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace SewerStammGen.EntityFramework.Migrations
-{
- ///
- public partial class SchachtRefProjectVirtual : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
-
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
-
- }
- }
-}
diff --git a/SewerStammGen.EntityFramework/Migrations/SewerStammGenDbContextModelSnapshot.cs b/SewerStammGen.EntityFramework/Migrations/SewerStammGenDbContextModelSnapshot.cs
index 9b2d27c..9d4342c 100644
--- a/SewerStammGen.EntityFramework/Migrations/SewerStammGenDbContextModelSnapshot.cs
+++ b/SewerStammGen.EntityFramework/Migrations/SewerStammGenDbContextModelSnapshot.cs
@@ -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 =>
diff --git a/SewerStammGen.EntityFramework/Services/HaltungDataService.cs b/SewerStammGen.EntityFramework/Services/HaltungDataService.cs
new file mode 100644
index 0000000..dbc2944
--- /dev/null
+++ b/SewerStammGen.EntityFramework/Services/HaltungDataService.cs
@@ -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 _nonQueryDataService;
+
+ public HaltungDataService(SewerStammGenDbContextFactory contextFactory)
+ {
+ _contextFactory = contextFactory;
+ _nonQueryDataService = new NonQueryDataService(contextFactory);
+ }
+ public async Task Create(Kanal entity)
+ {
+ return await _nonQueryDataService.Create(entity);
+ }
+
+ public Kanal CreateNonAsync(Kanal entity)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task Delete(int id)
+ {
+ throw new NotImplementedException();
+ }
+
+ public async Task Get(int id)
+ {
+ using (SewerStammGenDbContext context = _contextFactory.CreateDbContext())
+ {
+ Kanal entity = await context.Set()
+ .Include("StartSchacht")
+ .Include("EndSchacht")
+ .Include("Projekt")
+ .FirstOrDefaultAsync((e) => e.Id == id);
+ return entity;
+ }
+ }
+
+ public async Task> GetAll(int projektID)
+ {
+ using (SewerStammGenDbContext context = _contextFactory.CreateDbContext())
+ {
+ IEnumerable entities = await context.Set().Where(x => x.Projekt.Id.Equals(projektID)).ToListAsync();
+ return entities;
+ }
+ }
+
+ public Task> GetAll()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task Update(int id, Kanal entity)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/SewerStammGen/Commands/HaltungAddCommand.cs b/SewerStammGen/Commands/HaltungAddCommand.cs
new file mode 100644
index 0000000..527dcae
--- /dev/null
+++ b/SewerStammGen/Commands/HaltungAddCommand.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SewerStammGen.WPF.Commands
+{
+ internal class HaltungAddCommand : AsyncCommandBase
+ {
+ public HaltungAddCommand()
+ {
+
+ }
+
+ public override Task ExecuteAsync(object? parameter)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/SewerStammGen/Commands/HaltungEditCommand.cs b/SewerStammGen/Commands/HaltungEditCommand.cs
new file mode 100644
index 0000000..7f66554
--- /dev/null
+++ b/SewerStammGen/Commands/HaltungEditCommand.cs
@@ -0,0 +1,35 @@
+using SewerStammGen.Shared.Contracts;
+using SewerStammGen.WPF.Interface.Navigator;
+using SewerStammGen.WPF.ViewModel;
+using SewerStammGen.WPF.ViewModel.State;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+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)
+ {
+ this.haltungDataService = haltungDataService;
+ this.actualState = actualState;
+ this.renavigator = renavigator;
+ this.haltungListViewModel = haltungListViewModel;
+ }
+
+ public override async Task ExecuteAsync(object? parameter)
+ {
+ actualState.SetHaltung(haltungListViewModel.SelectedHaltung);
+ renavigator.Renavigate();
+ }
+ }
+}
diff --git a/SewerStammGen/Commands/SchachtAddCommand.cs b/SewerStammGen/Commands/SchachtAddCommand.cs
index 70011c7..3584058 100644
--- a/SewerStammGen/Commands/SchachtAddCommand.cs
+++ b/SewerStammGen/Commands/SchachtAddCommand.cs
@@ -13,16 +13,14 @@ namespace SewerStammGen.WPF.Commands
{
class SchachtAddCommand : AsyncCommandBase
{
- private readonly ISchachtDataService schachtDataService;
private readonly IActualState actualState;
private readonly IRenavigator renavigator;
private readonly IDataService projektService;
private readonly ISchachtService schachtService;
- public SchachtAddCommand(ISchachtDataService schachtDataService,IDataService projektService, IActualState actualState, IRenavigator renavigator, ISchachtService schachtService)
+ public SchachtAddCommand(IDataService projektService, IActualState actualState, IRenavigator renavigator, ISchachtService schachtService)
{
- this.schachtDataService = schachtDataService;
this.actualState = actualState;
this.renavigator = renavigator;
this.projektService = projektService;
@@ -31,13 +29,6 @@ namespace SewerStammGen.WPF.Commands
public override async Task ExecuteAsync(object? parameter)
{
- /*var d = await projektService.Get(actualState.ProjektID);
- Schacht newSchacht = new Schacht();
- newSchacht.Projekt = d;
- newSchacht.Objektbezeichnung = "test";
-
- await schachtDataService.Create(newSchacht);
- */
Projekt aktuelleProjekt = await projektService.Get(actualState.ProjektID);
Schacht schacht = await schachtService.CreateSchacht(aktuelleProjekt);
diff --git a/SewerStammGen/Commands/SchachtEditCommand.cs b/SewerStammGen/Commands/SchachtEditCommand.cs
index b2ac011..6b96adf 100644
--- a/SewerStammGen/Commands/SchachtEditCommand.cs
+++ b/SewerStammGen/Commands/SchachtEditCommand.cs
@@ -25,9 +25,10 @@ namespace SewerStammGen.WPF.Commands
this.manholeListViewModel = manholeListViewModel;
}
- public override Task ExecuteAsync(object? parameter)
+ public override async Task ExecuteAsync(object? parameter)
{
- throw new NotImplementedException();
+ actualState.SetSchacht(manholeListViewModel.SelectedSchacht);
+ renavigator.Renavigate();
}
}
}
diff --git a/SewerStammGen/Enum/EMainWindowViewType.cs b/SewerStammGen/Enum/EMainWindowViewType.cs
index abefca7..b38d4c1 100644
--- a/SewerStammGen/Enum/EMainWindowViewType.cs
+++ b/SewerStammGen/Enum/EMainWindowViewType.cs
@@ -12,6 +12,7 @@ namespace SewerStammGen.Enum
ProjectList,
SchachtList,
SchachtEdit,
+ HaltungList,
SewerConnectionEdit
}
}
diff --git a/SewerStammGen/HostBuilders/AddServicesHostBuilderExtensions.cs b/SewerStammGen/HostBuilders/AddServicesHostBuilderExtensions.cs
index 0359317..13966ff 100644
--- a/SewerStammGen/HostBuilders/AddServicesHostBuilderExtensions.cs
+++ b/SewerStammGen/HostBuilders/AddServicesHostBuilderExtensions.cs
@@ -26,7 +26,10 @@ namespace SewerStammGen.HostBuilders
services.AddSingleton();
services.AddSingleton>();
services.AddSingleton, GenericDataService>();
+ services.AddSingleton, GenericDataService>();
+ services.AddSingleton, GenericDataService>();
services.AddSingleton();
+ services.AddSingleton();
services.AddSingleton();
});
return host;
diff --git a/SewerStammGen/HostBuilders/AddViewModelsHostBuilderExtensions.cs b/SewerStammGen/HostBuilders/AddViewModelsHostBuilderExtensions.cs
index 403fbc5..723f078 100644
--- a/SewerStammGen/HostBuilders/AddViewModelsHostBuilderExtensions.cs
+++ b/SewerStammGen/HostBuilders/AddViewModelsHostBuilderExtensions.cs
@@ -33,6 +33,9 @@ namespace SewerStammGen.HostBuilders
services.AddSingleton>();
services.AddSingleton>();
+ services.AddSingleton>();
+ services.AddSingleton>();
+
services.AddSingleton>(services =>
{
return () => new HomeViewModel();
@@ -52,15 +55,32 @@ namespace SewerStammGen.HostBuilders
services.AddSingleton>(services =>
{
- return () => new ManholeEditViewModel();
+ return () => new ManholeEditViewModel(
+ services.GetRequiredService>(),
+ services.GetRequiredService()
+ );
});
#endregion
- services.AddSingleton>(services =>
+ #region Haltungen
+ services.AddSingleton>(services =>
{
- return () => new SewerConnectorViewModel();
+ return () => new HaltungListViewModel(
+ services.GetRequiredService(),
+ services.GetRequiredService(),
+ services.GetRequiredService>()
+ );
});
+ services.AddSingleton>(services =>
+ {
+ return () => new HaltungEditViewModel(
+ services.GetRequiredService(),
+ services.GetRequiredService()
+ );
+ });
+ #endregion
+
#region Projekte
services.AddSingleton>(services =>
{
diff --git a/SewerStammGen/MainWindow.xaml b/SewerStammGen/MainWindow.xaml
index 44431ce..6cf958b 100644
--- a/SewerStammGen/MainWindow.xaml
+++ b/SewerStammGen/MainWindow.xaml
@@ -20,11 +20,15 @@
-
+
-
-
+
+
+
+
+
+
diff --git a/SewerStammGen/SewerStammGen.WPF.csproj.user b/SewerStammGen/SewerStammGen.WPF.csproj.user
index 96277f6..909da7c 100644
--- a/SewerStammGen/SewerStammGen.WPF.csproj.user
+++ b/SewerStammGen/SewerStammGen.WPF.csproj.user
@@ -7,6 +7,12 @@
+
+ Code
+
+
+ Code
+
Code
@@ -22,20 +28,23 @@
Code
-
+
Code
Code
-
- Code
-
Designer
+
+ Designer
+
+
+ Designer
+
Designer
@@ -54,14 +63,11 @@
Designer
-
+
Designer
Designer
-
- Designer
-
\ No newline at end of file
diff --git a/SewerStammGen/ViewModel/Factories/MainWindowViewModelFactory.cs b/SewerStammGen/ViewModel/Factories/MainWindowViewModelFactory.cs
index 9444c4f..9941d05 100644
--- a/SewerStammGen/ViewModel/Factories/MainWindowViewModelFactory.cs
+++ b/SewerStammGen/ViewModel/Factories/MainWindowViewModelFactory.cs
@@ -13,22 +13,25 @@ namespace SewerStammGen.WPF.ViewModel.Factories
private CreateViewModel _createHomeViewModel;
private CreateViewModel _createManholeEditViewModel;
private CreateViewModel _createManholeListViewModel;
- private CreateViewModel _createSewerConnectorViewModel;
+ private CreateViewModel _createHaltungListViewModel;
+ //private CreateViewModel _createSewerConnectorViewModel;
private CreateViewModel _createProjektListViewModel;
public MainWindowViewModelFactory(
CreateViewModel createHomeViewModel,
CreateViewModel createManholeEditViewModel,
CreateViewModel createManholeListViewModel,
- CreateViewModel createSewerConnectorViewModel,
+ CreateViewModel createHaltungListViewModel,
+
CreateViewModel createProjektListViewModel
)
{
_createHomeViewModel = createHomeViewModel;
_createManholeEditViewModel = createManholeEditViewModel;
- _createSewerConnectorViewModel = createSewerConnectorViewModel;
+ //_createSewerConnectorViewModel = createSewerConnectorViewModel;
_createProjektListViewModel = createProjektListViewModel;
_createManholeListViewModel = createManholeListViewModel;
+ _createHaltungListViewModel = createHaltungListViewModel;
}
public BaseViewModel CreateViewModel(EMainWindowViewType viewType)
@@ -40,7 +43,8 @@ namespace SewerStammGen.WPF.ViewModel.Factories
case EMainWindowViewType.SchachtList: return _createManholeListViewModel();
case EMainWindowViewType.SchachtEdit: return _createManholeEditViewModel();
- case EMainWindowViewType.SewerConnectionEdit: return _createSewerConnectorViewModel();
+ case EMainWindowViewType.HaltungList: return _createHaltungListViewModel();
+ //case EMainWindowViewType.SewerConnectionEdit: return _createSewerConnectorViewModel();
case EMainWindowViewType.ProjectList: return _createProjektListViewModel();
diff --git a/SewerStammGen/ViewModel/Haltung/HaltungEditViewModel.cs b/SewerStammGen/ViewModel/Haltung/HaltungEditViewModel.cs
new file mode 100644
index 0000000..d0b64f8
--- /dev/null
+++ b/SewerStammGen/ViewModel/Haltung/HaltungEditViewModel.cs
@@ -0,0 +1,96 @@
+using SewerStammGen.Shared.Contracts;
+using SewerStammGen.WPF.ViewModel.State;
+using Shared.Contracts;
+using Shared.Domain;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Controls;
+using System.Windows.Input;
+
+namespace SewerStammGen.WPF.ViewModel
+{
+ internal class HaltungEditViewModel : BaseViewModel
+ {
+ private readonly IActualState _actualState;
+ private readonly IHaltungDataService _kanalDataService;
+ private Kanal _model;
+
+ public string Haltungsbezeichnung
+ {
+ get => _model.Objektbezeichnung;
+ set
+ {
+ if(_model.Objektbezeichnung != value)
+ {
+ _model.Objektbezeichnung = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+ public string Material
+ {
+ get => _model.Material;
+ set
+ {
+ if( _model.Material != value)
+ {
+ _model.Material = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+ public string Durchmesser
+ {
+ get => _model.DN.ToString();
+ set
+ {
+ if(_model.DN.ToString() != value)
+ {
+ _model.DN = int.Parse(value);
+ OnPropertyChanged();
+ }
+ }
+ }
+ public string Haltungslaenge
+ {
+ get => _model.Haltungslaenge.ToString();
+ set
+ {
+ if(_model.Haltungslaenge.ToString() != value)
+ {
+ _model.Haltungslaenge = decimal.Parse(value);
+ OnPropertyChanged();
+ }
+ }
+ }
+
+ public ICommand Speichern { get; set; }
+
+ public HaltungEditViewModel(IHaltungDataService kanalDataService, IActualState actualState)
+ {
+ _actualState = actualState;
+ _kanalDataService = kanalDataService;
+ _model = new Kanal();
+ Speichern = new RelayCommand((x) => SaveKanal());
+
+ LoadModel();
+ }
+
+ private void SaveKanal()
+ {
+ _kanalDataService.Update(_model.Id, _model);
+ }
+
+ private async void LoadModel()
+ {
+ _model = await _kanalDataService.Get(_actualState.HaltungID);
+ OnPropertyChanged(nameof(Haltungslaenge));
+ OnPropertyChanged(nameof(Haltungsbezeichnung));
+ OnPropertyChanged(nameof(Material));
+ OnPropertyChanged(nameof(Haltungslaenge));
+ }
+ }
+}
diff --git a/SewerStammGen/ViewModel/Haltung/HaltungListViewModel.cs b/SewerStammGen/ViewModel/Haltung/HaltungListViewModel.cs
new file mode 100644
index 0000000..0fb4826
--- /dev/null
+++ b/SewerStammGen/ViewModel/Haltung/HaltungListViewModel.cs
@@ -0,0 +1,56 @@
+using SewerStammGen.Shared.Contracts;
+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;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+
+namespace SewerStammGen.WPF.ViewModel
+{
+ public class HaltungListViewModel : BaseViewModel
+ {
+ private readonly ObservableCollection _haltungen;
+ private readonly IActualState _actualState;
+ private readonly IHaltungDataService _haltungDataService;
+
+ public Kanal? SelectedHaltung { get; set; }
+ public ObservableCollection Haltungen { get => _haltungen; }
+
+ public ICommand EditCommand { get; set; }
+ public ICommand AddCommand { get; set; }
+
+ public HaltungListViewModel(IHaltungDataService haltungDataService, IActualState actualState, IRenavigator renavigator )
+ {
+ _haltungen = new ObservableCollection();
+
+ _actualState = actualState;
+ _haltungDataService = haltungDataService;
+
+ EditCommand = new HaltungEditCommand(haltungDataService, actualState, renavigator, this);
+ AddCommand = new HaltungAddCommand();
+
+ LoadHaltungen();
+ }
+
+ private async void LoadHaltungen()
+ {
+ var haltungen = await _haltungDataService.GetAll(_actualState.ProjektID);
+ InitCollection(_haltungen, haltungen);
+ }
+
+ private void InitCollection(ObservableCollection dest, IEnumerable source)
+ {
+ dest.Clear();
+ foreach (var sourceItem in source)
+ {
+ dest.Add(sourceItem);
+ }
+ }
+ }
+}
diff --git a/SewerStammGen/ViewModel/ManholeEditViewModel.cs b/SewerStammGen/ViewModel/ManholeEditViewModel.cs
deleted file mode 100644
index 5fff1c1..0000000
--- a/SewerStammGen/ViewModel/ManholeEditViewModel.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SewerStammGen.WPF.ViewModel
-{
- public class ManholeEditViewModel : BaseViewModel
- {
- }
-}
diff --git a/SewerStammGen/ViewModel/Schacht/ManholeEditViewModel.cs b/SewerStammGen/ViewModel/Schacht/ManholeEditViewModel.cs
new file mode 100644
index 0000000..cdc0244
--- /dev/null
+++ b/SewerStammGen/ViewModel/Schacht/ManholeEditViewModel.cs
@@ -0,0 +1,126 @@
+using SewerStammGen.WPF.ViewModel.State;
+using Shared.Contracts;
+using Shared.Domain;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Input;
+
+namespace SewerStammGen.WPF.ViewModel
+{
+ public class ManholeEditViewModel : BaseViewModel
+ {
+ private readonly IActualState _actualState;
+ private readonly IDataService _schachtDataService;
+
+ private Schacht _model;
+
+ public ICommand Speichern { get; set; }
+
+ public string Objektbezeichnung
+ {
+ get
+ {
+ return _model.Objektbezeichnung;
+ }
+ set
+ {
+ if(_model.Objektbezeichnung != value)
+ {
+ _model.Objektbezeichnung = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+ public decimal RechtsWert
+ {
+ get => _model.RechtsWert;
+ set
+ {
+ if(_model.RechtsWert != value)
+ {
+ _model.RechtsWert = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+ public decimal HochWert
+ {
+ get => _model.HochWert; set
+ {
+ if (_model.HochWert != value)
+ {
+ _model.HochWert = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+ public decimal DeckelHoehe
+ {
+ get => _model.DeckelHoehe;
+ set
+ {
+ if (_model.DeckelHoehe != value)
+ {
+ _model.DeckelHoehe = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+ public decimal SohlHoehe
+ {
+ get => _model.SohlHoehe;
+ set
+ {
+ if (_model.SohlHoehe != value)
+ {
+ _model.SohlHoehe = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+ public EEntwaeserung Entwaeserung
+ {
+ get => _model.Entwaesserung;
+ set
+ {
+ if (_model.Entwaesserung != value)
+ {
+ _model.Entwaesserung = value;
+ OnPropertyChanged();
+ }
+ }
+ }
+
+ public ManholeEditViewModel(IDataService schachtDataService,IActualState actualState)
+ {
+ _actualState = actualState;
+ _schachtDataService = schachtDataService;
+ _model = new Schacht();
+
+ Speichern = new RelayCommand((x) => SaveSchacht());
+
+ LoadModel();
+
+
+ }
+
+ private 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));
+ }
+ }
+}
diff --git a/SewerStammGen/ViewModel/Schacht/ManholeListViewModel.cs b/SewerStammGen/ViewModel/Schacht/ManholeListViewModel.cs
index fda91dd..ed2827a 100644
--- a/SewerStammGen/ViewModel/Schacht/ManholeListViewModel.cs
+++ b/SewerStammGen/ViewModel/Schacht/ManholeListViewModel.cs
@@ -16,35 +16,37 @@ namespace SewerStammGen.WPF.ViewModel
{
public class ManholeListViewModel : BaseViewModel
{
- private ISchachtDataService _schachtService;
+ private ISchachtDataService _schachtDataService;
private readonly ObservableCollection _schaechte;
private readonly IActualState _actualState;
- private readonly ISchachtService _schachtServicer;
+ private readonly ISchachtService _schachtService;
public ObservableCollection Schaechte { get => _schaechte; }
+ public Schacht? SelectedSchacht { get; set; }
+
public ICommand AddSchachtCommand { get; set; }
public ICommand EditSchachtCommand { get; set; }
public ICommand DeleteSchachtCommand { get; set; }
- public ManholeListViewModel(ISchachtDataService schachtService, IDataService projektService,IRenavigator renavigator ,IActualState actualState, ISchachtService schachtServicer)
+ public ManholeListViewModel(ISchachtDataService schachtDataService, IDataService projektService,IRenavigator renavigator ,IActualState actualState, ISchachtService schachtService)
{
- _schachtService = schachtService;
+ _schachtDataService = schachtDataService;
_actualState = actualState;
_schaechte = new ObservableCollection();
- _schachtServicer = schachtServicer;
+ _schachtService = schachtService;
- AddSchachtCommand = new SchachtAddCommand(schachtService,projektService, actualState,renavigator,schachtServicer);
- EditSchachtCommand = new SchachtEditCommand(schachtService, actualState, renavigator,this);
- DeleteSchachtCommand = new SchachtDeleteCommand(schachtService, actualState, renavigator, this);
+ AddSchachtCommand = new SchachtAddCommand(projektService, actualState,renavigator,schachtService);
+ EditSchachtCommand = new SchachtEditCommand(schachtDataService, actualState, renavigator,this);
+ DeleteSchachtCommand = new SchachtDeleteCommand(schachtDataService, actualState, renavigator, this);
LoadSchaechte();
}
private async void LoadSchaechte()
{
- var schaechte = await _schachtService.GetAll(_actualState.ProjektID);
+ var schaechte = await _schachtDataService.GetAll(_actualState.ProjektID);
InitCollection(_schaechte, schaechte);
}
diff --git a/SewerStammGen/ViewModel/SewerConnectorViewModel.cs b/SewerStammGen/ViewModel/SewerConnectorViewModel.cs
deleted file mode 100644
index 8ccd35a..0000000
--- a/SewerStammGen/ViewModel/SewerConnectorViewModel.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SewerStammGen.WPF.ViewModel
-{
- public class SewerConnectorViewModel : BaseViewModel
- {
- }
-}
diff --git a/SewerStammGen/ViewModel/State/ActualState.cs b/SewerStammGen/ViewModel/State/ActualState.cs
index 24a407f..620d54e 100644
--- a/SewerStammGen/ViewModel/State/ActualState.cs
+++ b/SewerStammGen/ViewModel/State/ActualState.cs
@@ -12,6 +12,9 @@ namespace SewerStammGen.WPF.ViewModel.State
// TODO: set auf private set setzen
public int ProjektID { get; set; }
+ public int SchachtID { get; private set; }
+ public int HaltungID { get; private set; }
+
public void SetProjekt(Projekt projekt, bool notification = true)
{
ProjektID = projekt.Id;
@@ -20,12 +23,39 @@ namespace SewerStammGen.WPF.ViewModel.State
OnProjektChanged();
}
}
+ public void SetSchacht(Schacht schacht, bool notification = true)
+ {
+ SchachtID = schacht.Id;
+ if(notification)
+ {
+ OnSchachtChanged();
+ }
+ }
+ public void SetHaltung(Kanal haltung, bool notification = true)
+ {
+ HaltungID = haltung.Id;
+ if(notification)
+ {
+ OnHaltungChanged();
+ }
+ }
public event EventHandler? ProjektChanged;
+ public event EventHandler? SchachtChanged;
+ public event EventHandler? HaltungChanged;
private void OnProjektChanged()
{
ProjektChanged?.Invoke(this, new EventArgs());
}
+ private void OnSchachtChanged()
+ {
+ SchachtChanged?.Invoke(this, new EventArgs());
+ }
+ private void OnHaltungChanged()
+ {
+ HaltungChanged?.Invoke(this, new EventArgs());
+ }
+
}
}
diff --git a/SewerStammGen/ViewModel/State/IActualState.cs b/SewerStammGen/ViewModel/State/IActualState.cs
index 57665a3..da532ff 100644
--- a/SewerStammGen/ViewModel/State/IActualState.cs
+++ b/SewerStammGen/ViewModel/State/IActualState.cs
@@ -12,7 +12,11 @@ namespace SewerStammGen.WPF.ViewModel.State
event EventHandler? ProjektChanged;
// TODO: ProjektID set entfernen!
int ProjektID { get; set; }
+ int SchachtID { get; }
+ int HaltungID { get; }
void SetProjekt(Projekt projekt, bool notification = true);
+ void SetSchacht(Schacht schacht, bool notification = true);
+ void SetHaltung(Kanal haltung, bool notification = true);
}
}
diff --git a/SewerStammGen/Views/Controls/UCMainWindowNavigationBar.xaml b/SewerStammGen/Views/Controls/UCMainWindowNavigationBar.xaml
index 592ccf0..a729a0e 100644
--- a/SewerStammGen/Views/Controls/UCMainWindowNavigationBar.xaml
+++ b/SewerStammGen/Views/Controls/UCMainWindowNavigationBar.xaml
@@ -18,7 +18,7 @@
-
+
diff --git a/SewerStammGen/Views/Haltung/HaltungEditView.xaml b/SewerStammGen/Views/Haltung/HaltungEditView.xaml
new file mode 100644
index 0000000..53ca95b
--- /dev/null
+++ b/SewerStammGen/Views/Haltung/HaltungEditView.xaml
@@ -0,0 +1,105 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SewerStammGen/Views/UCSewerConnector.xaml.cs b/SewerStammGen/Views/Haltung/HaltungEditView.xaml.cs
similarity index 78%
rename from SewerStammGen/Views/UCSewerConnector.xaml.cs
rename to SewerStammGen/Views/Haltung/HaltungEditView.xaml.cs
index ccaf50b..3fed6fd 100644
--- a/SewerStammGen/Views/UCSewerConnector.xaml.cs
+++ b/SewerStammGen/Views/Haltung/HaltungEditView.xaml.cs
@@ -16,11 +16,11 @@ using System.Windows.Shapes;
namespace SewerStammGen.WPF.Views
{
///
- /// Interaktionslogik für UCSewerConnector.xaml
+ /// Interaktionslogik für HaltungEditView.xaml
///
- public partial class UCSewerConnector : UserControl
+ public partial class HaltungEditView : UserControl
{
- public UCSewerConnector()
+ public HaltungEditView()
{
InitializeComponent();
}
diff --git a/SewerStammGen/Views/Haltung/HaltungListView.xaml b/SewerStammGen/Views/Haltung/HaltungListView.xaml
new file mode 100644
index 0000000..0795531
--- /dev/null
+++ b/SewerStammGen/Views/Haltung/HaltungListView.xaml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SewerStammGen/Views/Haltung/HaltungListView.xaml.cs b/SewerStammGen/Views/Haltung/HaltungListView.xaml.cs
new file mode 100644
index 0000000..d9478c8
--- /dev/null
+++ b/SewerStammGen/Views/Haltung/HaltungListView.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+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 SewerStammGen.WPF.Views
+{
+ ///
+ /// Interaktionslogik für HaltungListView.xaml
+ ///
+ public partial class HaltungListView : UserControl
+ {
+ public HaltungListView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/SewerStammGen/Views/UCEditSchacht.xaml b/SewerStammGen/Views/Schacht/SchachtEditView.xaml
similarity index 89%
rename from SewerStammGen/Views/UCEditSchacht.xaml
rename to SewerStammGen/Views/Schacht/SchachtEditView.xaml
index f35af8c..6b7446d 100644
--- a/SewerStammGen/Views/UCEditSchacht.xaml
+++ b/SewerStammGen/Views/Schacht/SchachtEditView.xaml
@@ -1,4 +1,4 @@
-
-
-
-
-
-
+
+
+
+
+
@@ -41,7 +41,7 @@
-
+
diff --git a/SewerStammGen/Views/UCEditSchacht.xaml.cs b/SewerStammGen/Views/Schacht/SchachtEditView.xaml.cs
similarity index 86%
rename from SewerStammGen/Views/UCEditSchacht.xaml.cs
rename to SewerStammGen/Views/Schacht/SchachtEditView.xaml.cs
index 6bf4849..42352a6 100644
--- a/SewerStammGen/Views/UCEditSchacht.xaml.cs
+++ b/SewerStammGen/Views/Schacht/SchachtEditView.xaml.cs
@@ -18,9 +18,9 @@ namespace SewerStammGen.WPF.Views
///
/// Interaktionslogik für UCEditSchacht.xaml
///
- public partial class UCEditSchacht : UserControl
+ public partial class SchachtEditView : UserControl
{
- public UCEditSchacht()
+ public SchachtEditView()
{
InitializeComponent();
}
diff --git a/SewerStammGen/Views/Schacht/SchachtListView.xaml b/SewerStammGen/Views/Schacht/SchachtListView.xaml
index 29edeb2..fd17efb 100644
--- a/SewerStammGen/Views/Schacht/SchachtListView.xaml
+++ b/SewerStammGen/Views/Schacht/SchachtListView.xaml
@@ -8,7 +8,7 @@
d:DesignHeight="450" d:DesignWidth="800">
-
+
@@ -19,8 +19,8 @@
-
-
+
+
diff --git a/SewerStammGen/Views/UCSewerConnector.xaml b/SewerStammGen/Views/UCSewerConnector.xaml
deleted file mode 100644
index 7b2e6fb..0000000
--- a/SewerStammGen/Views/UCSewerConnector.xaml
+++ /dev/null
@@ -1,102 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Shared/Contracts/IHaltungDataService.cs b/Shared/Contracts/IHaltungDataService.cs
new file mode 100644
index 0000000..7e02da3
--- /dev/null
+++ b/Shared/Contracts/IHaltungDataService.cs
@@ -0,0 +1,15 @@
+using Shared.Contracts;
+using Shared.Domain;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SewerStammGen.Shared.Contracts
+{
+ public interface IHaltungDataService : IDataService
+ {
+ Task> GetAll(int projektID);
+ }
+}
diff --git a/Shared/Domain/Kanal.cs b/Shared/Domain/Kanal.cs
index 1b7f184..c78b1d6 100644
--- a/Shared/Domain/Kanal.cs
+++ b/Shared/Domain/Kanal.cs
@@ -14,6 +14,7 @@ namespace Shared.Domain
public int DN { get; set; }
public string? Material { get; set; }
public decimal Haltungslaenge { get; set; }
+ public virtual Projekt? Projekt { get; set; }
public EEntwaeserung Entwaesserung { get; set; }
}