Schächte werden nun hinzugefügt

This commit is contained in:
2023-03-31 15:01:39 +02:00
parent 70bba66df3
commit d4b38ff7ae
33 changed files with 927 additions and 30 deletions

View File

@@ -0,0 +1,222 @@
// <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("20230331095322_SchachtRefProject")]
partial class SchachtRefProject
{
/// <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

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

View File

@@ -0,0 +1,222 @@
// <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

@@ -0,0 +1,22 @@
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

@@ -200,9 +200,11 @@ namespace SewerStammGen.EntityFramework.Migrations
modelBuilder.Entity("Shared.Domain.Schacht", b =>
{
b.HasOne("Shared.Domain.Projekt", null)
b.HasOne("Shared.Domain.Projekt", "Projekt")
.WithMany("Schaechte")
.HasForeignKey("ProjektId");
b.Navigation("Projekt");
});
modelBuilder.Entity("Shared.Domain.Projekt", b =>

View File

@@ -0,0 +1,63 @@
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 SchachtDataService : ISchachtDataService
{
private readonly SewerStammGenDbContextFactory _contextFactory;
private readonly NonQueryDataService<Schacht> _nonQueryDataService;
public SchachtDataService(SewerStammGenDbContextFactory contextFactory)
{
_contextFactory = contextFactory;
_nonQueryDataService = new NonQueryDataService<Schacht>(contextFactory);
}
public async Task<Schacht> Create(Schacht entity)
{
return await _nonQueryDataService.Create(entity);
}
public Schacht CreateNonAsync(Schacht entity)
{
throw new NotImplementedException();
}
public Task<bool> Delete(int id)
{
throw new NotImplementedException();
}
public Task<Schacht> Get(int id)
{
throw new NotImplementedException();
}
public async Task<IEnumerable<Schacht>> GetAll(int projektID)
{
using (SewerStammGenDbContext context = _contextFactory.CreateDbContext())
{
IEnumerable<Schacht> entities = await context.Set<Schacht>().Where(x => x.Projekt.Id.Equals(projektID)).ToListAsync();
return entities;
}
}
public Task<IEnumerable<Schacht>> GetAll()
{
throw new NotImplementedException();
}
public async Task<Schacht> Update(int id, Schacht entity)
{
return await _nonQueryDataService.Update(id, entity);
}
}
}

View File

@@ -0,0 +1,46 @@
using SewerStammGen.Shared.Contracts;
using SewerStammGen.WPF.Interface.Navigator;
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;
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)
{
this.schachtDataService = schachtDataService;
this.actualState = actualState;
this.renavigator = renavigator;
this.projektService = projektService;
this.schachtService = schachtService;
}
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

@@ -0,0 +1,33 @@
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
{
class SchachtDeleteCommand : AsyncCommandBase
{
private ISchachtDataService schachtService;
private IActualState actualState;
private IRenavigator renavigator;
private ManholeListViewModel manholeListViewModel;
public SchachtDeleteCommand(ISchachtDataService schachtService, IActualState actualState, IRenavigator renavigator, ManholeListViewModel manholeListViewModel)
{
this.schachtService = schachtService;
this.actualState = actualState;
this.renavigator = renavigator;
this.manholeListViewModel = manholeListViewModel;
}
public override Task ExecuteAsync(object? parameter)
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,33 @@
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
{
class SchachtEditCommand : AsyncCommandBase
{
private ISchachtDataService schachtService;
private IActualState actualState;
private IRenavigator renavigator;
private ManholeListViewModel manholeListViewModel;
public SchachtEditCommand(ISchachtDataService schachtService, IActualState actualState, IRenavigator renavigator, ManholeListViewModel manholeListViewModel)
{
this.schachtService = schachtService;
this.actualState = actualState;
this.renavigator = renavigator;
this.manholeListViewModel = manholeListViewModel;
}
public override Task ExecuteAsync(object? parameter)
{
throw new NotImplementedException();
}
}
}

View File

@@ -9,8 +9,9 @@ namespace SewerStammGen.Enum
public enum EMainWindowViewType
{
Home,
ProjectsList,
EditSchacht,
ProjectList,
SchachtList,
SchachtEdit,
SewerConnectionEdit
}
}

View File

@@ -1,6 +1,8 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SewerStammGen.EntityFramework.Services;
using SewerStammGen.Shared.Contracts;
using SewerStammGen.Shared.Services;
using SewerStammGen.WPF.Interface.Navigator;
using SewerStammGen.WPF.ViewModel;
using SewerStammGen.WPF.ViewModel.State.Navigation;
@@ -24,6 +26,8 @@ namespace SewerStammGen.HostBuilders
services.AddSingleton<IMainWindowNavigator, MainWindowNavigator>();
services.AddSingleton<ViewModelDelegateRenavigator<ProjektEditViewModel>>();
services.AddSingleton<IDataService<Projekt>, GenericDataService<Projekt>>();
services.AddSingleton<ISchachtDataService, SchachtDataService>();
services.AddSingleton<ISchachtService, SchachtService>();
});
return host;
}

View File

@@ -14,6 +14,7 @@ using System.Net.Security;
using System.Text;
using System.Threading.Tasks;
using SewerStammGen.WPF.ViewModel.State;
using SewerStammGen.Shared.Contracts;
namespace SewerStammGen.HostBuilders
{
@@ -29,21 +30,38 @@ namespace SewerStammGen.HostBuilders
services.AddSingleton<ViewModelDelegateRenavigator<ProjektListViewModel>>();
services.AddSingleton<ViewModelDelegateRenavigator<ProjektEditViewModel>>();
services.AddSingleton<ViewModelDelegateRenavigator<ManholeListViewModel>>();
services.AddSingleton<ViewModelDelegateRenavigator<ManholeEditViewModel>>();
services.AddSingleton<CreateViewModel<HomeViewModel>>(services =>
{
return () => new HomeViewModel();
});
services.AddSingleton<CreateViewModel<EditManHoleViewModel>>(services =>
#region Schächte
services.AddSingleton<CreateViewModel<ManholeListViewModel>>(services =>
{
return () => new EditManHoleViewModel();
return () => new ManholeListViewModel(
services.GetRequiredService<ISchachtDataService>(),
services.GetRequiredService<IDataService<Projekt>>(),
services.GetRequiredService<ViewModelDelegateRenavigator<ManholeEditViewModel>>(),
services.GetRequiredService<IActualState>(),
services.GetRequiredService<ISchachtService>()
);
});
services.AddSingleton<CreateViewModel<ManholeEditViewModel>>(services =>
{
return () => new ManholeEditViewModel();
});
#endregion
services.AddSingleton<CreateViewModel<SewerConnectorViewModel>>(services =>
{
return () => new SewerConnectorViewModel();
});
#region Projekte
services.AddSingleton<CreateViewModel<ProjektEditViewModel>>(services =>
{
return () => new ProjektEditViewModel(
@@ -61,6 +79,7 @@ namespace SewerStammGen.HostBuilders
services.GetRequiredService<IActualState>()
);
});
#endregion
services.AddSingleton<IViewModelAbstractFactory, MainWindowViewModelFactory>();
});

View File

@@ -16,7 +16,10 @@
<DataTemplate DataType="{x:Type viewmodel:HomeViewModel}">
<view:HomeView />
</DataTemplate>
<DataTemplate DataType="{x:Type viewmodel:EditManHoleViewModel}">
<DataTemplate DataType="{x:Type viewmodel:ManholeListViewModel}">
<view:SchachtListView />
</DataTemplate>
<DataTemplate DataType="{x:Type viewmodel:ManholeEditViewModel}">
<view:UCEditSchacht />
</DataTemplate>
<DataTemplate DataType="{x:Type viewmodel:SewerConnectorViewModel}">

View File

@@ -13,10 +13,13 @@
<Compile Update="Views\HomeView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\Projekte\ProjektEditView.xaml.cs">
<Compile Update="Views\Projekt\ProjektEditView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\Projekte\ProjektListView.xaml.cs">
<Compile Update="Views\Projekt\ProjektListView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\Schacht\SchachtListView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="Views\UCEditSchacht.xaml.cs">
@@ -39,10 +42,13 @@
<Page Update="Views\HomeView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Views\Projekte\ProjektEditView.xaml">
<Page Update="Views\Projekt\ProjektEditView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Views\Projekte\ProjektListView.xaml">
<Page Update="Views\Projekt\ProjektListView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Views\Schacht\SchachtListView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Views\styles\my_controls.xaml">

View File

@@ -11,37 +11,38 @@ namespace SewerStammGen.WPF.ViewModel.Factories
public class MainWindowViewModelFactory : IViewModelAbstractFactory
{
private CreateViewModel<HomeViewModel> _createHomeViewModel;
private CreateViewModel<EditManHoleViewModel> _createEditManholeViewModel;
private CreateViewModel<ManholeEditViewModel> _createManholeEditViewModel;
private CreateViewModel<ManholeListViewModel> _createManholeListViewModel;
private CreateViewModel<SewerConnectorViewModel> _createSewerConnectorViewModel;
private CreateViewModel<ProjektListViewModel> _createProjektListViewModel;
public MainWindowViewModelFactory(
CreateViewModel<HomeViewModel> createHomeViewModel,
CreateViewModel<EditManHoleViewModel> createEditManholeViewModel,
CreateViewModel<ManholeEditViewModel> createManholeEditViewModel,
CreateViewModel<ManholeListViewModel> createManholeListViewModel,
CreateViewModel<SewerConnectorViewModel> createSewerConnectorViewModel,
CreateViewModel<ProjektListViewModel> createProjektListViewModel
)
{
_createHomeViewModel = createHomeViewModel;
_createEditManholeViewModel = createEditManholeViewModel;
_createManholeEditViewModel = createManholeEditViewModel;
_createSewerConnectorViewModel = createSewerConnectorViewModel;
_createProjektListViewModel = createProjektListViewModel;
_createManholeListViewModel = createManholeListViewModel;
}
public BaseViewModel CreateViewModel(EMainWindowViewType viewType)
{
switch(viewType)
{
case EMainWindowViewType.Home:
return _createHomeViewModel();
case EMainWindowViewType.Home: return _createHomeViewModel();
case EMainWindowViewType.EditSchacht:
return _createEditManholeViewModel();
case EMainWindowViewType.SchachtList: return _createManholeListViewModel();
case EMainWindowViewType.SchachtEdit: return _createManholeEditViewModel();
case EMainWindowViewType.SewerConnectionEdit:
return _createSewerConnectorViewModel();
case EMainWindowViewType.SewerConnectionEdit: return _createSewerConnectorViewModel();
case EMainWindowViewType.ProjectsList: return _createProjektListViewModel();
case EMainWindowViewType.ProjectList: return _createProjektListViewModel();
default:
throw new NotImplementedException();

View File

@@ -45,6 +45,12 @@ namespace SewerStammGen.WPF.ViewModel
Navigator.StateChanged += Navigator_StateChanged;
#if DEBUG
_actualState.ProjektID = 5;
#endif
}
private void ActualState_ProjektChanged(object? sender, EventArgs e)

View File

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace SewerStammGen.WPF.ViewModel
{
public class EditManHoleViewModel : BaseViewModel
public class ManholeEditViewModel : BaseViewModel
{
}
}

View File

@@ -0,0 +1,60 @@
using SewerStammGen.Shared.Contracts;
using SewerStammGen.WPF.Commands;
using SewerStammGen.WPF.Interface.Navigator;
using SewerStammGen.WPF.ViewModel.State;
using Shared.Contracts;
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 ManholeListViewModel : BaseViewModel
{
private ISchachtDataService _schachtService;
private readonly ObservableCollection<Schacht> _schaechte;
private readonly IActualState _actualState;
private readonly ISchachtService _schachtServicer;
public ObservableCollection<Schacht> Schaechte { get => _schaechte; }
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)
{
_schachtService = schachtService;
_actualState = actualState;
_schaechte = new ObservableCollection<Schacht>();
_schachtServicer = schachtServicer;
AddSchachtCommand = new SchachtAddCommand(schachtService,projektService, actualState,renavigator,schachtServicer);
EditSchachtCommand = new SchachtEditCommand(schachtService, actualState, renavigator,this);
DeleteSchachtCommand = new SchachtDeleteCommand(schachtService, actualState, renavigator, this);
LoadSchaechte();
}
private async void LoadSchaechte()
{
var schaechte = await _schachtService.GetAll(_actualState.ProjektID);
InitCollection(_schaechte, schaechte);
}
private void InitCollection(ObservableCollection<Schacht> dest, IEnumerable<Schacht> source)
{
dest.Clear();
foreach(var i in source)
{
dest.Add(i);
}
}
}
}

View File

@@ -9,7 +9,8 @@ namespace SewerStammGen.WPF.ViewModel.State
{
internal class ActualState : IActualState
{
public int ProjektID { get; private set; }
// TODO: set auf private set setzen
public int ProjektID { get; set; }
public void SetProjekt(Projekt projekt, bool notification = true)
{

View File

@@ -10,8 +10,8 @@ namespace SewerStammGen.WPF.ViewModel.State
public interface IActualState
{
event EventHandler? ProjektChanged;
int ProjektID { get; }
// TODO: ProjektID set entfernen!
int ProjektID { get; set; }
void SetProjekt(Projekt projekt, bool notification = true);
}

View File

@@ -16,8 +16,8 @@
<Grid>
<StackPanel>
<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.ProjectsList}" Style="{StaticResource ToggleButtonList}" Content="Projekte" />
<RadioButton IsChecked="{Binding CurrentViewModel, Mode=OneWay, Converter={StaticResource EqualValueToParameterConverter}, ConverterParameter={x:Type viewmodel:EditManHoleViewModel}}" Command="{Binding UpdateCurrentViewModelCommand}" CommandParameter="{x:Static nav:EMainWindowViewType.EditSchacht}" Style="{StaticResource ToggleButtonList}" Content="Schächte" />
<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" />
</StackPanel>

View File

@@ -8,7 +8,7 @@
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<StackPanel>
<DataGrid FontSize="20" Margin="10" SelectedItem="{Binding SelectedProjekt}" ItemsSource="{Binding Projekte}" IsReadOnly="True" SelectionMode="Single" AutoGenerateColumns="False">
<DataGrid Margin="10" SelectedItem="{Binding SelectedProjekt}" ItemsSource="{Binding Projekte}" IsReadOnly="True" SelectionMode="Single" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Projektname" Binding="{Binding Projektname}" />
<DataGridTextColumn Header="Erstelldatum" Binding="{Binding Erstelldatum}" />

View File

@@ -0,0 +1,27 @@
<UserControl x:Class="SewerStammGen.WPF.Views.SchachtListView"
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 Schaechte}" AutoGenerateColumns="False" IsReadOnly="True" SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn Header="Schachtnummer" Binding="{Binding Objektbezeichnung}" />
<DataGridTextColumn Header="Rechtswert" Binding="{Binding RechtsWert}" />
<DataGridTextColumn Header="Hochwert" Binding="{Binding HochWert}" />
<DataGridTextColumn Header="Sohlhöhe" Binding="{Binding SohlHoehe}" />
<DataGridTextColumn Header="Deckelhöhe" Binding="{Binding DeckelHoehe}" />
<DataGridTextColumn Header="Entwässerung" Binding="{Binding Entwaesserung}" />
</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}" />
</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 SchachtList.xaml
/// </summary>
public partial class SchachtListView : UserControl
{
public SchachtListView()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,14 @@
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 IProjektDataService : IDataService<Projekt>
{
}
}

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 ISchachtDataService : IDataService<Schacht>
{
Task<IEnumerable<Schacht>> GetAll(int projektID);
}
}

View File

@@ -0,0 +1,14 @@
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 ISchachtService
{
Task<Schacht> CreateSchacht(Projekt proj);
}
}

View File

@@ -16,7 +16,7 @@ namespace Shared.Domain
public Auftraggeber Auftraggeber { get; set; }
public EExportType ExportType { get; set; }
public EKodierungssystem Kodierungssystem { get; set; }
public IList<Kanal> Kanaele { get; set; }
public IList<Schacht> Schaechte { get; set;}
public IList<Kanal> Kanaele { get; set; } = new List<Kanal>();
public IList<Schacht> Schaechte { get; set;} = new List<Schacht>();
}
}

View File

@@ -9,7 +9,7 @@ namespace Shared.Domain
{
public class Schacht : DBObject
{
public string? Objektbezeichnung { get; set; }
public string? Objektbezeichnung { get; set; }
[Column(TypeName = "decimal(18,4)")]
public decimal RechtsWert { get; set; }
@@ -22,6 +22,8 @@ namespace Shared.Domain
[Column(TypeName = "decimal(18,4)")]
public decimal DeckelHoehe { get; set; }
public virtual Projekt? Projekt { get; set; }
public EEntwaeserung Entwaesserung { get; set; }
}

View File

@@ -0,0 +1,31 @@
using SewerStammGen.Shared.Contracts;
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.Services
{
public class SchachtService : ISchachtService
{
private readonly IDataService<Projekt> _projectService;
public SchachtService(IDataService<Projekt> projectService)
{
_projectService = projectService;
}
public async Task<Schacht> CreateSchacht(Projekt proj)
{
Schacht schacht = new Schacht() {
Projekt = proj
};
proj.Schaechte.Add(schacht);
await _projectService.Update(proj.Id, proj);
return schacht;
}
}
}