Code cleanup
This commit is contained in:
@@ -15,23 +15,23 @@ namespace SewerStammGen.WPF.Commands
|
||||
{
|
||||
private HaltungEditViewModel haltungEditViewModel;
|
||||
private IDataService<Kanal> kanalDataService;
|
||||
private ISchachtService schachtService;
|
||||
|
||||
|
||||
public HaltungEditSaveCommand(HaltungEditViewModel haltungEditViewModel, ISchachtService schachtService)
|
||||
public HaltungEditSaveCommand(HaltungEditViewModel haltungEditViewModel)
|
||||
{
|
||||
this.haltungEditViewModel = haltungEditViewModel;
|
||||
//this.kanalDataService = kanalDataService;
|
||||
this.schachtService = schachtService;
|
||||
|
||||
}
|
||||
|
||||
public override async Task ExecuteAsync(object? parameter)
|
||||
{
|
||||
if(haltungEditViewModel._oberePunkt != haltungEditViewModel.Model.StartSchacht.Objektbezeichnung)
|
||||
{
|
||||
Schacht s = await schachtService.FindSchachtByNameAndProjektID(haltungEditViewModel._oberePunkt, haltungEditViewModel.Model.Projekt.Id);
|
||||
haltungEditViewModel.Model.StartSchacht = s;
|
||||
//Schacht s = await schachtService.FindSchachtByNameAndProjektID(haltungEditViewModel._oberePunkt, haltungEditViewModel.Model.Projekt.Id);
|
||||
//haltungEditViewModel.Model.StartSchacht = s;
|
||||
}
|
||||
haltungEditViewModel.Model = await kanalDataService.Update(haltungEditViewModel.Model.Id, haltungEditViewModel.Model);
|
||||
//haltungEditViewModel.Model = await kanalDataService.Update(haltungEditViewModel.Model.Id, haltungEditViewModel.Model);
|
||||
Trace.WriteLine("Daten gespeichert");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,21 +16,20 @@ namespace SewerStammGen.WPF.Commands
|
||||
private readonly IActualState actualState;
|
||||
private readonly IRenavigator renavigator;
|
||||
private readonly IDataService<Projekt> projektService;
|
||||
private readonly ISchachtService schachtService;
|
||||
|
||||
|
||||
public SchachtAddCommand(IDataService<Projekt> projektService, IActualState actualState, IRenavigator renavigator, ISchachtService schachtService)
|
||||
public SchachtAddCommand(IDataService<Projekt> projektService, IActualState actualState, IRenavigator renavigator)
|
||||
{
|
||||
this.actualState = actualState;
|
||||
this.renavigator = renavigator;
|
||||
this.projektService = projektService;
|
||||
this.schachtService = schachtService;
|
||||
|
||||
}
|
||||
|
||||
public override async Task ExecuteAsync(object? parameter)
|
||||
{
|
||||
Projekt aktuelleProjekt = await projektService.Get(actualState.ProjektID);
|
||||
Schacht schacht = await schachtService.CreateSchacht(aktuelleProjekt);
|
||||
// Schacht schacht = await schachtService.CreateSchacht(aktuelleProjekt);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using SewerStammGen.DAL.Services;
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using SewerStammGen.Shared.Services;
|
||||
using SewerStammGen.WPF.Interface.Navigator;
|
||||
using SewerStammGen.WPF.ViewModel;
|
||||
using SewerStammGen.WPF.ViewModel.State.Navigation;
|
||||
@@ -28,7 +27,7 @@ namespace SewerStammGen.HostBuilders
|
||||
services.AddSingleton<IProjektDataService, ProjektDataService>();
|
||||
services.AddSingleton<IAuftraggeberDataService, AuftraggeberDataService>();
|
||||
|
||||
services.AddSingleton<ISchachtService, SchachtService>();
|
||||
|
||||
});
|
||||
return host;
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ namespace SewerStammGen.HostBuilders
|
||||
services.GetRequiredService<ISchachtDataService>(),
|
||||
services.GetRequiredService<IDataService<Projekt>>(),
|
||||
services.GetRequiredService<ViewModelDelegateRenavigator<ManholeEditViewModel>>(),
|
||||
services.GetRequiredService<IActualState>(),
|
||||
services.GetRequiredService<ISchachtService>()
|
||||
services.GetRequiredService<IActualState>()
|
||||
|
||||
);
|
||||
});
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace SewerStammGen.HostBuilders
|
||||
{
|
||||
return () => new HaltungEditViewModel(
|
||||
|
||||
services.GetRequiredService<ISchachtService>(),
|
||||
|
||||
services.GetRequiredService<IActualState>()
|
||||
);
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
{
|
||||
private readonly IActualState _actualState;
|
||||
//private readonly IHaltungDataService _kanalDataService;
|
||||
private readonly ISchachtService _schachtService;
|
||||
|
||||
private Kanal _model;
|
||||
|
||||
public Kanal Model
|
||||
@@ -113,14 +113,14 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
public ICommand Speichern { get; set; }
|
||||
|
||||
public HaltungEditViewModel(
|
||||
ISchachtService schachtService,
|
||||
|
||||
IActualState actualState)
|
||||
{
|
||||
_actualState = actualState;
|
||||
//_kanalDataService = kanalDataService;
|
||||
_schachtService = schachtService;
|
||||
|
||||
_model = new Kanal();
|
||||
Speichern = new HaltungEditSaveCommand(this, schachtService);
|
||||
Speichern = new HaltungEditSaveCommand(this);
|
||||
|
||||
LoadModel();
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
}
|
||||
else
|
||||
{
|
||||
_dataService.Update(_model.Id, _model);
|
||||
_dataService.Update(_model);
|
||||
}
|
||||
_renavigator.Renavigate();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,9 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
private async void LoadProjekte()
|
||||
{
|
||||
var projects = await genericDataService.GetAll();
|
||||
|
||||
InitCollection(_projekte, projects);
|
||||
|
||||
}
|
||||
|
||||
private void InitCollection(ObservableCollection<Projekt> projekte, IEnumerable<Projekt> projects)
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
|
||||
private void SaveSchacht()
|
||||
{
|
||||
_schachtDataService.Update(_model.Id, _model);
|
||||
//_schachtDataService.Update(_model.Id, _model);
|
||||
}
|
||||
|
||||
private async void LoadModel()
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
private ISchachtDataService _schachtDataService;
|
||||
private readonly ObservableCollection<Schacht> _schaechte;
|
||||
private readonly IActualState _actualState;
|
||||
private readonly ISchachtService _schachtService;
|
||||
|
||||
public ObservableCollection<Schacht> Schaechte { get => _schaechte; }
|
||||
|
||||
public Schacht? SelectedSchacht { get; set; }
|
||||
@@ -29,15 +29,15 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
public ICommand DeleteSchachtCommand { get; set; }
|
||||
|
||||
|
||||
public ManholeListViewModel(ISchachtDataService schachtDataService, IDataService<Projekt> projektService,IRenavigator renavigator ,IActualState actualState, ISchachtService schachtService)
|
||||
public ManholeListViewModel(ISchachtDataService schachtDataService, IDataService<Projekt> projektService,IRenavigator renavigator ,IActualState actualState)
|
||||
{
|
||||
_schachtDataService = schachtDataService;
|
||||
_actualState = actualState;
|
||||
|
||||
_schaechte = new ObservableCollection<Schacht>();
|
||||
_schachtService = schachtService;
|
||||
|
||||
|
||||
AddSchachtCommand = new SchachtAddCommand(projektService, actualState,renavigator,schachtService);
|
||||
AddSchachtCommand = new SchachtAddCommand(projektService, actualState,renavigator);
|
||||
EditSchachtCommand = new SchachtEditCommand(schachtDataService, actualState, renavigator,this);
|
||||
DeleteSchachtCommand = new SchachtDeleteCommand(schachtDataService, actualState, renavigator, this);
|
||||
|
||||
@@ -46,8 +46,8 @@ namespace SewerStammGen.WPF.ViewModel
|
||||
|
||||
private async void LoadSchaechte()
|
||||
{
|
||||
var schaechte = await _schachtDataService.GetAll(_actualState.ProjektID);
|
||||
InitCollection(_schaechte, schaechte);
|
||||
//var schaechte = await _schachtDataService.GetAll(_actualState.ProjektID);
|
||||
//InitCollection(_schaechte, schaechte);
|
||||
}
|
||||
|
||||
private void InitCollection(ObservableCollection<Schacht> dest, IEnumerable<Schacht> source)
|
||||
|
||||
Reference in New Issue
Block a user