Projekt kann nun Selectiert werden
This commit is contained in:
@@ -245,10 +245,24 @@ namespace KanSan.ViewModel
|
||||
Mediator.Subscribe("GoToEditClientScreen", OnGoToEditClientScreen);
|
||||
Mediator.Subscribe("ClientSelected", OnSelectedClient);
|
||||
|
||||
Mediator.Subscribe("GoToListProjektScreen", OnGoToListProjektScreen);
|
||||
Mediator.Subscribe("GoToEditProjektScreen", OnGoToEditProjektScreen);
|
||||
Mediator.Subscribe("ProjektSelected", OnSelectedProjekt);
|
||||
|
||||
}
|
||||
|
||||
private void OnSelectedProjekt(object obj)
|
||||
{
|
||||
if (!(obj is Projekt)) return;
|
||||
SelectedProjekt = (obj as Projekt);
|
||||
ListBaustellen();
|
||||
}
|
||||
|
||||
private void OnGoToListProjektScreen(object obj)
|
||||
{
|
||||
ListProjekte();
|
||||
}
|
||||
|
||||
private void OnGoToEditProjektScreen(object obj)
|
||||
{
|
||||
if (!(obj is Projekt)) return;
|
||||
|
||||
@@ -2,16 +2,20 @@
|
||||
using KanSan.Base.Interfaces;
|
||||
using KanSan.Base.Interfaces.UI;
|
||||
using KanSan.Base.Models;
|
||||
using KanSan.ViewModel.Commands;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
public class ProjektEditViewModel : BaseViewModel,INotifyPropertyChanged, IProjektEditViewModel
|
||||
{
|
||||
IUnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
|
||||
public ICommand SaveProjekt { get; set; }
|
||||
public ICommand RemoveProjekt { get; set; }
|
||||
private Projekt projekt;
|
||||
string projektnummer;
|
||||
string ort;
|
||||
@@ -41,6 +45,7 @@ namespace KanSan.ViewModel
|
||||
this.projekt = projekt;
|
||||
projektnummer = projekt.Projektnummer;
|
||||
ort = projekt.Ort;
|
||||
SaveProjekt = new RelayCommand(parameter => Speichern());
|
||||
}
|
||||
|
||||
public void Speichern()
|
||||
@@ -49,6 +54,7 @@ namespace KanSan.ViewModel
|
||||
projekt.Projektnummer = Projektnummer;
|
||||
unitOfWork.ProjekteRepository.Update(projekt);
|
||||
unitOfWork.Commit();
|
||||
Mediator.Notify("GoToListProjektScreen");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,17 @@ namespace KanSan.ViewModel
|
||||
|
||||
projektevonKunde = unitOfWork.ProjekteRepository.Get(x => x.Kunde.Equals(client)).ToList();
|
||||
|
||||
SelectProjekt = new RelayCommand(parameter => SelectActualProjekt());
|
||||
EditProjekt = new RelayCommand(parameter => EditSelectedProjekt());
|
||||
NewProjekt = new RelayCommand(parameter => AddNewProjekt());
|
||||
}
|
||||
|
||||
private void SelectActualProjekt()
|
||||
{
|
||||
if (SelectedProjekt == null) return;
|
||||
Mediator.Notify("ProjektSelected", SelectedProjekt);
|
||||
}
|
||||
|
||||
private void AddNewProjekt()
|
||||
{
|
||||
Projekt newProj = NeueProjekt();
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
<Label Background="Beige" Grid.Column="0" Grid.Row="0" Content="Projektnummer" />
|
||||
<Label Background="Beige" Grid.Column="0" Grid.Row="1" Content="Ort" />
|
||||
<Button Grid.Row="2" Grid.ColumnSpan="2" Name="Speichern" Content="Speichern" />
|
||||
<Button Grid.Row="2" Grid.ColumnSpan="2" Name="Speichern" Content="Speichern" Command="{Binding SaveProjekt}" />
|
||||
|
||||
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Projektnummer}" />
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding Ort}" />
|
||||
|
||||
Reference in New Issue
Block a user