Haltungübersicht angefangen
This commit is contained in:
126
SewerStammGen/ViewModel/Schacht/ManholeEditViewModel.cs
Normal file
126
SewerStammGen/ViewModel/Schacht/ManholeEditViewModel.cs
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user