Haltungübersicht angefangen

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

View File

@@ -1,222 +0,0 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using SewerStammGen.EntityFramework;
#nullable disable
namespace SewerStammGen.EntityFramework.Migrations
{
[DbContext(typeof(SewerStammGenDbContext))]
[Migration("20230331121831_SchachtRefProjectVirtual")]
partial class SchachtRefProjectVirtual
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Shared.Domain.Auftraggeber", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Ansprechpartner")
.HasColumnType("text");
b.Property<string>("Name")
.HasColumnType("text");
b.Property<string>("Ort")
.HasColumnType("text");
b.Property<string>("Postleitzahl")
.HasColumnType("text");
b.Property<string>("Strasse")
.HasColumnType("text");
b.Property<string>("Telefonnummer")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Auftraggebers");
});
modelBuilder.Entity("Shared.Domain.Kanal", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("DN")
.HasColumnType("integer");
b.Property<int?>("EndSchachtId")
.HasColumnType("integer");
b.Property<int>("Entwaesserung")
.HasColumnType("integer");
b.Property<decimal>("Haltungslaenge")
.HasColumnType("numeric");
b.Property<string>("Material")
.HasColumnType("text");
b.Property<string>("Objektbezeichnung")
.HasColumnType("text");
b.Property<int?>("ProjektId")
.HasColumnType("integer");
b.Property<int?>("StartSchachtId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("EndSchachtId");
b.HasIndex("ProjektId");
b.HasIndex("StartSchachtId");
b.ToTable("Kanaele");
});
modelBuilder.Entity("Shared.Domain.Projekt", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("AuftraggeberId")
.HasColumnType("integer");
b.Property<string>("Erstelldatum")
.HasColumnType("text");
b.Property<int>("ExportType")
.HasColumnType("integer");
b.Property<int>("Kodierungssystem")
.HasColumnType("integer");
b.Property<string>("Ort")
.HasColumnType("text");
b.Property<string>("Projektname")
.HasColumnType("text");
b.Property<string>("Strasse")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("AuftraggeberId");
b.ToTable("Projekte");
});
modelBuilder.Entity("Shared.Domain.Schacht", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("DeckelHoehe")
.HasColumnType("decimal(18,4)");
b.Property<int>("Entwaesserung")
.HasColumnType("integer");
b.Property<decimal>("HochWert")
.HasColumnType("decimal(18,4)");
b.Property<string>("Objektbezeichnung")
.HasColumnType("text");
b.Property<int?>("ProjektId")
.HasColumnType("integer");
b.Property<decimal>("RechtsWert")
.HasColumnType("decimal(18,4)");
b.Property<decimal>("SohlHoehe")
.HasColumnType("decimal(18,4)");
b.HasKey("Id");
b.HasIndex("ProjektId");
b.ToTable("Schaechte");
});
modelBuilder.Entity("Shared.Domain.Kanal", b =>
{
b.HasOne("Shared.Domain.Schacht", "EndSchacht")
.WithMany()
.HasForeignKey("EndSchachtId");
b.HasOne("Shared.Domain.Projekt", null)
.WithMany("Kanaele")
.HasForeignKey("ProjektId");
b.HasOne("Shared.Domain.Schacht", "StartSchacht")
.WithMany()
.HasForeignKey("StartSchachtId");
b.Navigation("EndSchacht");
b.Navigation("StartSchacht");
});
modelBuilder.Entity("Shared.Domain.Projekt", b =>
{
b.HasOne("Shared.Domain.Auftraggeber", "Auftraggeber")
.WithMany()
.HasForeignKey("AuftraggeberId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Auftraggeber");
});
modelBuilder.Entity("Shared.Domain.Schacht", b =>
{
b.HasOne("Shared.Domain.Projekt", "Projekt")
.WithMany("Schaechte")
.HasForeignKey("ProjektId");
b.Navigation("Projekt");
});
modelBuilder.Entity("Shared.Domain.Projekt", b =>
{
b.Navigation("Kanaele");
b.Navigation("Schaechte");
});
#pragma warning restore 612, 618
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,70 @@
using Microsoft.EntityFrameworkCore;
using SewerStammGen.EntityFramework.Services.Common;
using SewerStammGen.Shared.Contracts;
using Shared.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SewerStammGen.EntityFramework.Services
{
public class HaltungDataService : IHaltungDataService
{
private readonly SewerStammGenDbContextFactory _contextFactory;
private readonly NonQueryDataService<Kanal> _nonQueryDataService;
public HaltungDataService(SewerStammGenDbContextFactory contextFactory)
{
_contextFactory = contextFactory;
_nonQueryDataService = new NonQueryDataService<Kanal>(contextFactory);
}
public async Task<Kanal> Create(Kanal entity)
{
return await _nonQueryDataService.Create(entity);
}
public Kanal CreateNonAsync(Kanal entity)
{
throw new NotImplementedException();
}
public Task<bool> Delete(int id)
{
throw new NotImplementedException();
}
public async Task<Kanal> Get(int id)
{
using (SewerStammGenDbContext context = _contextFactory.CreateDbContext())
{
Kanal entity = await context.Set<Kanal>()
.Include("StartSchacht")
.Include("EndSchacht")
.Include("Projekt")
.FirstOrDefaultAsync((e) => e.Id == id);
return entity;
}
}
public async Task<IEnumerable<Kanal>> GetAll(int projektID)
{
using (SewerStammGenDbContext context = _contextFactory.CreateDbContext())
{
IEnumerable<Kanal> entities = await context.Set<Kanal>().Where(x => x.Projekt.Id.Equals(projektID)).ToListAsync();
return entities;
}
}
public Task<IEnumerable<Kanal>> GetAll()
{
throw new NotImplementedException();
}
public Task<Kanal> Update(int id, Kanal entity)
{
throw new NotImplementedException();
}
}
}

View File

@@ -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();
}
}
}

View File

@@ -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();
}
}
}

View File

@@ -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<Projekt> projektService;
private readonly ISchachtService schachtService;
public SchachtAddCommand(ISchachtDataService schachtDataService,IDataService<Projekt> projektService, IActualState actualState, IRenavigator renavigator, ISchachtService schachtService)
public SchachtAddCommand(IDataService<Projekt> 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);

View File

@@ -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();
}
}
}

View File

@@ -12,6 +12,7 @@ namespace SewerStammGen.Enum
ProjectList,
SchachtList,
SchachtEdit,
HaltungList,
SewerConnectionEdit
}
}

View File

@@ -26,7 +26,10 @@ namespace SewerStammGen.HostBuilders
services.AddSingleton<IMainWindowNavigator, MainWindowNavigator>();
services.AddSingleton<ViewModelDelegateRenavigator<ProjektEditViewModel>>();
services.AddSingleton<IDataService<Projekt>, GenericDataService<Projekt>>();
services.AddSingleton<IDataService<Schacht>, GenericDataService<Schacht>>();
services.AddSingleton<IDataService<Kanal>, GenericDataService<Kanal>>();
services.AddSingleton<ISchachtDataService, SchachtDataService>();
services.AddSingleton<IHaltungDataService, HaltungDataService>();
services.AddSingleton<ISchachtService, SchachtService>();
});
return host;

View File

@@ -33,6 +33,9 @@ namespace SewerStammGen.HostBuilders
services.AddSingleton<ViewModelDelegateRenavigator<ManholeListViewModel>>();
services.AddSingleton<ViewModelDelegateRenavigator<ManholeEditViewModel>>();
services.AddSingleton<ViewModelDelegateRenavigator<HaltungListViewModel>>();
services.AddSingleton<ViewModelDelegateRenavigator<HaltungEditViewModel>>();
services.AddSingleton<CreateViewModel<HomeViewModel>>(services =>
{
return () => new HomeViewModel();
@@ -52,15 +55,32 @@ namespace SewerStammGen.HostBuilders
services.AddSingleton<CreateViewModel<ManholeEditViewModel>>(services =>
{
return () => new ManholeEditViewModel();
return () => new ManholeEditViewModel(
services.GetRequiredService<IDataService<Schacht>>(),
services.GetRequiredService<IActualState>()
);
});
#endregion
services.AddSingleton<CreateViewModel<SewerConnectorViewModel>>(services =>
#region Haltungen
services.AddSingleton<CreateViewModel<HaltungListViewModel>>(services =>
{
return () => new SewerConnectorViewModel();
return () => new HaltungListViewModel(
services.GetRequiredService<IHaltungDataService>(),
services.GetRequiredService<IActualState>(),
services.GetRequiredService<ViewModelDelegateRenavigator<HaltungEditViewModel>>()
);
});
services.AddSingleton<CreateViewModel<HaltungEditViewModel>>(services =>
{
return () => new HaltungEditViewModel(
services.GetRequiredService<IHaltungDataService>(),
services.GetRequiredService<IActualState>()
);
});
#endregion
#region Projekte
services.AddSingleton<CreateViewModel<ProjektEditViewModel>>(services =>
{

View File

@@ -20,11 +20,15 @@
<view:SchachtListView />
</DataTemplate>
<DataTemplate DataType="{x:Type viewmodel:ManholeEditViewModel}">
<view:UCEditSchacht />
<view:SchachtEditView />
</DataTemplate>
<DataTemplate DataType="{x:Type viewmodel:SewerConnectorViewModel}">
<view:UCSewerConnector />
<DataTemplate DataType="{x:Type viewmodel:HaltungListViewModel}">
<view:HaltungListView />
</DataTemplate>
<DataTemplate DataType="{x:Type viewmodel:HaltungEditViewModel}">
<view:HaltungEditView />
</DataTemplate>
<DataTemplate DataType="{x:Type viewmodel:ProjektListViewModel}">
<view:ProjektListView />
</DataTemplate>

View File

@@ -7,6 +7,12 @@
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Compile Update="Views\Haltung\HaltungEditView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\Haltung\HaltungListView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\Controls\UCMainWindowNavigationBar.xaml.cs">
<SubType>Code</SubType>
</Compile>
@@ -22,20 +28,23 @@
<Compile Update="Views\Schacht\SchachtListView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\UCEditSchacht.xaml.cs">
<Compile Update="Views\Schacht\SchachtEditView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\UCNormXML.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\UCSewerConnector.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Page Update="MainWindow.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Views\Haltung\HaltungEditView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Views\Haltung\HaltungListView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Views\Controls\UCMainWindowNavigationBar.xaml">
<SubType>Designer</SubType>
</Page>
@@ -54,14 +63,11 @@
<Page Update="Views\styles\my_controls.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Views\UCEditSchacht.xaml">
<Page Update="Views\Schacht\SchachtEditView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Views\UCNormXML.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Views\UCSewerConnector.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
</Project>

View File

@@ -13,22 +13,25 @@ namespace SewerStammGen.WPF.ViewModel.Factories
private CreateViewModel<HomeViewModel> _createHomeViewModel;
private CreateViewModel<ManholeEditViewModel> _createManholeEditViewModel;
private CreateViewModel<ManholeListViewModel> _createManholeListViewModel;
private CreateViewModel<SewerConnectorViewModel> _createSewerConnectorViewModel;
private CreateViewModel<HaltungListViewModel> _createHaltungListViewModel;
//private CreateViewModel<SewerConnectorViewModel> _createSewerConnectorViewModel;
private CreateViewModel<ProjektListViewModel> _createProjektListViewModel;
public MainWindowViewModelFactory(
CreateViewModel<HomeViewModel> createHomeViewModel,
CreateViewModel<ManholeEditViewModel> createManholeEditViewModel,
CreateViewModel<ManholeListViewModel> createManholeListViewModel,
CreateViewModel<SewerConnectorViewModel> createSewerConnectorViewModel,
CreateViewModel<HaltungListViewModel> createHaltungListViewModel,
CreateViewModel<ProjektListViewModel> 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();

View File

@@ -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));
}
}
}

View File

@@ -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<Kanal> _haltungen;
private readonly IActualState _actualState;
private readonly IHaltungDataService _haltungDataService;
public Kanal? SelectedHaltung { get; set; }
public ObservableCollection<Kanal> Haltungen { get => _haltungen; }
public ICommand EditCommand { get; set; }
public ICommand AddCommand { get; set; }
public HaltungListViewModel(IHaltungDataService haltungDataService, IActualState actualState, IRenavigator renavigator )
{
_haltungen = new ObservableCollection<Kanal>();
_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<Kanal> dest, IEnumerable<Kanal> source)
{
dest.Clear();
foreach (var sourceItem in source)
{
dest.Add(sourceItem);
}
}
}
}

View File

@@ -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
{
}
}

View File

@@ -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<Schacht> _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<Schacht> 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));
}
}
}

View File

@@ -16,35 +16,37 @@ namespace SewerStammGen.WPF.ViewModel
{
public class ManholeListViewModel : BaseViewModel
{
private ISchachtDataService _schachtService;
private ISchachtDataService _schachtDataService;
private readonly ObservableCollection<Schacht> _schaechte;
private readonly IActualState _actualState;
private readonly ISchachtService _schachtServicer;
private readonly ISchachtService _schachtService;
public ObservableCollection<Schacht> 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<Projekt> projektService,IRenavigator renavigator ,IActualState actualState, ISchachtService schachtServicer)
public ManholeListViewModel(ISchachtDataService schachtDataService, IDataService<Projekt> projektService,IRenavigator renavigator ,IActualState actualState, ISchachtService schachtService)
{
_schachtService = schachtService;
_schachtDataService = schachtDataService;
_actualState = actualState;
_schaechte = new ObservableCollection<Schacht>();
_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);
}

View File

@@ -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
{
}
}

View File

@@ -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());
}
}
}

View File

@@ -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);
}
}

View File

@@ -18,7 +18,7 @@
<RadioButton IsChecked="{Binding CurrentViewModel, Mode=OneWay, Converter={StaticResource EqualValueToParameterConverter}, ConverterParameter={x:Type viewmodel:HomeViewModel}}" Command="{Binding UpdateCurrentViewModelCommand}" CommandParameter="{x:Static nav:EMainWindowViewType.Home}" Style="{StaticResource ToggleButtonList}" Content="Home" />
<RadioButton IsChecked="{Binding CurrentViewModel, Mode=OneWay, Converter={StaticResource EqualValueToParameterConverter}, ConverterParameter={x:Type viewmodel:ProjektListViewModel}}" Command="{Binding UpdateCurrentViewModelCommand}" CommandParameter="{x:Static nav:EMainWindowViewType.ProjectList}" Style="{StaticResource ToggleButtonList}" Content="Projekte" />
<RadioButton IsChecked="{Binding CurrentViewModel, Mode=OneWay, Converter={StaticResource EqualValueToParameterConverter}, ConverterParameter={x:Type viewmodel:ManholeListViewModel}}" Command="{Binding UpdateCurrentViewModelCommand}" CommandParameter="{x:Static nav:EMainWindowViewType.SchachtList}" Style="{StaticResource ToggleButtonList}" Content="Schächte" />
<RadioButton IsChecked="{Binding CurrentViewModel, Mode=OneWay, Converter={StaticResource EqualValueToParameterConverter}, ConverterParameter={x:Type viewmodel:SewerConnectorViewModel}}" Command="{Binding UpdateCurrentViewModelCommand}" CommandParameter="{x:Static nav:EMainWindowViewType.SewerConnectionEdit}" Style="{StaticResource ToggleButtonList}" Content="Haltungen" />
<RadioButton IsChecked="{Binding CurrentViewModel, Mode=OneWay, Converter={StaticResource EqualValueToParameterConverter}, ConverterParameter={x:Type viewmodel:HaltungListViewModel}}" Command="{Binding UpdateCurrentViewModelCommand}" CommandParameter="{x:Static nav:EMainWindowViewType.HaltungList}" Style="{StaticResource ToggleButtonList}" Content="Haltungen" />
</StackPanel>
</Grid>

View File

@@ -0,0 +1,105 @@
<UserControl x:Class="SewerStammGen.WPF.Views.HaltungEditView"
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:syncfusion="http://schemas.syncfusion.com/wpf"
xmlns:local="clr-namespace:SewerStammGen.WPF.Views"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<DataTemplate x:Key="headerTemplate">
<TextBox></TextBox>
</DataTemplate>
</UserControl.Resources>
<Grid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="Obere Schacht" />
<Label Grid.Row="1" Grid.Column="0" Content="Untere Schacht" />
<Label Grid.Row="2" Grid.Column="0" Content="Haltungsbezeichnung" />
<syncfusion:SfMultiColumnDropDownControl Grid.Column="1" Grid.Row="0"
Width="250"
Margin="10,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
AllowAutoComplete="True"
AllowImmediatePopup="True"
AllowIncrementalFiltering="True"
AutoGenerateColumns="False"
DisplayMember="Title"
HeaderTemplate="{StaticResource headerTemplate}"
PopupWidth="400"
ValueMember="Cast"
>
</syncfusion:SfMultiColumnDropDownControl>
<syncfusion:SfMultiColumnDropDownControl Grid.Column="1" Grid.Row="1"
Width="250"
Margin="10,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
AllowAutoComplete="True"
AllowImmediatePopup="True"
AllowIncrementalFiltering="True"
AutoGenerateColumns="False"
DisplayMember="Title"
HeaderTemplate="{StaticResource headerTemplate}"
PopupWidth="400"
ValueMember="Cast"
></syncfusion:SfMultiColumnDropDownControl>
<TextBox Grid.Row="2" Grid.Column="1" Margin="5" Text="{Binding Haltungsbezeichnung}" />
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="59*" />
<ColumnDefinition Width="241*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Label VerticalAlignment="Center" Grid.Column="0" Content="Material" />
<Label VerticalAlignment="Center" Grid.Row="1" Grid.Column="0" Content="Durchmesser" />
<Label VerticalAlignment="Center" Grid.Row="2" Grid.Column="0" Content="Haltungslänge" />
<Label VerticalAlignment="Center" Grid.Row="3" Grid.Column="0" Content="Entwässerungsart" />
<TextBox Grid.Row="0" Grid.Column="1" Margin="5,5,5,5" Text="{Binding Material}" Grid.ColumnSpan="2" />
<TextBox Grid.Row="1" Grid.Column="1" Margin="5,5,5,5" Text="{Binding Durchmesser}" Grid.ColumnSpan="2" />
<TextBox Grid.Row="2" Grid.Column="1" Margin="5,5,5,5" Text="{Binding Haltungslaenge}" Grid.ColumnSpan="2" />
<DockPanel Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="2">
<RadioButton Style="{StaticResource ToggleButtonList}" Content="Regenwasser" />
<RadioButton Style="{StaticResource ToggleButtonList}" Content="Schmutzwasser" />
<RadioButton Style="{StaticResource ToggleButtonList}" Content="Mischwasser" />
</DockPanel>
</Grid>
<StackPanel Grid.Row="4">
<Button Content="Speichern" />
</StackPanel>
</Grid>
</Grid>
</UserControl>

View File

@@ -16,11 +16,11 @@ using System.Windows.Shapes;
namespace SewerStammGen.WPF.Views
{
/// <summary>
/// Interaktionslogik für UCSewerConnector.xaml
/// Interaktionslogik für HaltungEditView.xaml
/// </summary>
public partial class UCSewerConnector : UserControl
public partial class HaltungEditView : UserControl
{
public UCSewerConnector()
public HaltungEditView()
{
InitializeComponent();
}

View File

@@ -0,0 +1,19 @@
<UserControl x:Class="SewerStammGen.WPF.Views.HaltungListView"
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:SewerStammGen.WPF.Views"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<StackPanel>
<DataGrid ItemsSource="{Binding Haltungen}" SelectedItem="{Binding SelectedHaltung}">
</DataGrid>
<Button Content="Hinzufügen" Command="{Binding AddCommand}" />
<Button Content="Editieren" Command="{Binding EditCommand}" />
</StackPanel>
</Grid>
</UserControl>

View File

@@ -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
{
/// <summary>
/// Interaktionslogik für HaltungListView.xaml
/// </summary>
public partial class HaltungListView : UserControl
{
public HaltungListView()
{
InitializeComponent();
}
}
}

View File

@@ -1,4 +1,4 @@
<UserControl x:Class="SewerStammGen.WPF.Views.UCEditSchacht"
<UserControl x:Class="SewerStammGen.WPF.Views.SchachtEditView"
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"
@@ -28,11 +28,11 @@
<Label Grid.Column="0" Grid.Row="4" Content="Deckelhöhe" />
<Label Grid.Column="0" Grid.Row="5" Content="Entwässerungsart" />
<TextBox Margin="2" Grid.Column="1" Grid.Row="0" Text="{Binding X}" />
<TextBox Margin="2" Grid.Column="1" Grid.Row="1" Text="{Binding X}" />
<TextBox Margin="2" Grid.Column="1" Grid.Row="2" Text="{Binding X}" />
<TextBox Margin="2" Grid.Column="1" Grid.Row="3" Text="{Binding X}" />
<TextBox Margin="2" Grid.Column="1" Grid.Row="4" Text="{Binding X}" />
<TextBox Margin="2" Grid.Column="1" Grid.Row="0" Text="{Binding Objektbezeichnung}" />
<TextBox Margin="2" Grid.Column="1" Grid.Row="1" Text="{Binding RechtsWert}" />
<TextBox Margin="2" Grid.Column="1" Grid.Row="2" Text="{Binding HochWert}" />
<TextBox Margin="2" Grid.Column="1" Grid.Row="3" Text="{Binding SohlHoehe}" />
<TextBox Margin="2" Grid.Column="1" Grid.Row="4" Text="{Binding DeckelHoehe}" />
<DockPanel Grid.Column="1" Grid.Row="5">
<RadioButton Style="{StaticResource ToggleButtonList}" Content="Regenwasser" />
<RadioButton Style="{StaticResource ToggleButtonList}" Content="Schmutzwasser" />
@@ -41,7 +41,7 @@
<StackPanel Grid.ColumnSpan="2" Grid.Row="6">
<Button FontSize="20" Content="Speichern" />
<Button Content="Speichern" Command="{Binding Speichern}" />
</StackPanel>
</Grid>

View File

@@ -18,9 +18,9 @@ namespace SewerStammGen.WPF.Views
/// <summary>
/// Interaktionslogik für UCEditSchacht.xaml
/// </summary>
public partial class UCEditSchacht : UserControl
public partial class SchachtEditView : UserControl
{
public UCEditSchacht()
public SchachtEditView()
{
InitializeComponent();
}

View File

@@ -8,7 +8,7 @@
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<StackPanel>
<DataGrid ItemsSource="{Binding Schaechte}" AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single">
<DataGrid ItemsSource="{Binding Schaechte}" AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single" SelectedItem="{Binding SelectedSchacht}">
<DataGrid.Columns>
<DataGridTextColumn Header="Schachtnummer" Binding="{Binding Objektbezeichnung}" />
<DataGridTextColumn Header="Rechtswert" Binding="{Binding RechtsWert}" />
@@ -19,8 +19,8 @@
</DataGrid.Columns>
</DataGrid>
<Button Content="Schacht hinzufügen" Command="{Binding AddSchachtCommand}" />
<Button Content="Schacht Editieren" Command="{Binding EditSchacht}" />
<Button Content="Schacht Löschen" Command="{Binding DeleteSchacht}" />
<Button Content="Schacht Editieren" Command="{Binding EditSchachtCommand}" />
<Button Content="Schacht Löschen" Command="{Binding DeleteSchachtCommand}" />
</StackPanel>
</Grid>

View File

@@ -1,102 +0,0 @@
<UserControl x:Class="SewerStammGen.WPF.Views.UCSewerConnector"
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:syncfusion="http://schemas.syncfusion.com/wpf"
xmlns:local="clr-namespace:SewerStammGen.WPF.Views"
mc:Ignorable="d"
d:DesignHeight="450" Width="1028">
<UserControl.Resources>
<DataTemplate x:Key="headerTemplate">
<TextBox></TextBox>
</DataTemplate>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="Obere Schacht" />
<Label Grid.Row="1" Grid.Column="0" Content="Untere Schacht" />
<Label Grid.Row="2" Grid.Column="0" Content="Haltungsbezeichnung" />
<syncfusion:SfMultiColumnDropDownControl Grid.Column="1" Grid.Row="0"
Width="250"
Margin="10,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
AllowAutoComplete="True"
AllowImmediatePopup="True"
AllowIncrementalFiltering="True"
AutoGenerateColumns="False"
DisplayMember="Title"
HeaderTemplate="{StaticResource headerTemplate}"
PopupWidth="400"
ValueMember="Cast"
>
</syncfusion:SfMultiColumnDropDownControl>
<syncfusion:SfMultiColumnDropDownControl Grid.Column="1" Grid.Row="1"
Width="250"
Margin="10,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
AllowAutoComplete="True"
AllowImmediatePopup="True"
AllowIncrementalFiltering="True"
AutoGenerateColumns="False"
DisplayMember="Title"
HeaderTemplate="{StaticResource headerTemplate}"
PopupWidth="400"
ValueMember="Cast"
></syncfusion:SfMultiColumnDropDownControl>
<TextBox Grid.Row="2" Grid.Column="1" Margin="5" />
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Label VerticalAlignment="Center" Grid.Row="0" Grid.Column="0" Content="Material" />
<Label VerticalAlignment="Center" Grid.Row="1" Grid.Column="0" Content="Durchmesser" />
<Label VerticalAlignment="Center" Grid.Row="2" Grid.Column="0" Content="Haltungslänge" />
<Label VerticalAlignment="Center" Grid.Row="3" Grid.Column="0" Content="Entwässerungsart" />
<TextBox Grid.Row="0" Grid.Column="1" Margin="5" Text="{Binding X}" />
<TextBox Grid.Row="1" Grid.Column="1" Margin="5" Text="{Binding X}" />
<TextBox Grid.Row="2" Grid.Column="1" Margin="5" Text="{Binding X}" />
<DockPanel Grid.Row="3" Grid.Column="1">
<RadioButton Style="{StaticResource ToggleButtonList}" Content="Regenwasser" />
<RadioButton Style="{StaticResource ToggleButtonList}" Content="Schmutzwasser" />
<RadioButton Style="{StaticResource ToggleButtonList}" Content="Mischwasser" />
</DockPanel>
</Grid>
<StackPanel Grid.Row="4">
<Button Content="Speichern" />
</StackPanel>
</Grid>
</UserControl>

View File

@@ -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<Kanal>
{
Task<IEnumerable<Kanal>> GetAll(int projektID);
}
}

View File

@@ -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; }
}