Projekte integration angefangen
This commit is contained in:
@@ -2,10 +2,13 @@
|
||||
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.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace KanSan.ViewModel
|
||||
{
|
||||
@@ -22,26 +25,38 @@ namespace KanSan.ViewModel
|
||||
}
|
||||
private Kunde selectedKunde;
|
||||
|
||||
public ICommand NewProjekt { get; set; }
|
||||
public ICommand EditProjekt { get; set; }
|
||||
public ICommand SelectProjekt { get; set; }
|
||||
public Projekt SelectedProjekt { get; set; }
|
||||
|
||||
public ProjektListViewModel(Kunde client)
|
||||
{
|
||||
|
||||
this.selectedKunde = client;
|
||||
|
||||
|
||||
projektevonKunde = unitOfWork.ProjekteRepository.Get(x => x.Kunde.Equals(client)).ToList();
|
||||
|
||||
EditProjekt = new RelayCommand(parameter => EditSelectedProjekt());
|
||||
NewProjekt = new RelayCommand(parameter => AddNewProjekt());
|
||||
}
|
||||
|
||||
public void SelectProjekt()
|
||||
private void AddNewProjekt()
|
||||
{
|
||||
Projekt newProj = NeueProjekt();
|
||||
Mediator.Notify("GoToEditProjektScreen", newProj);
|
||||
}
|
||||
|
||||
private void EditSelectedProjekt()
|
||||
{
|
||||
Mediator.Notify("GoToEditProjektScreen", SelectedProjekt);
|
||||
}
|
||||
|
||||
public Projekt NeueProjekt()
|
||||
{
|
||||
Guid guid = Guid.NewGuid();
|
||||
Projekt newProjekt = new Projekt()
|
||||
{
|
||||
GuidNr = guid,
|
||||
GuidNr = Guid.NewGuid(),
|
||||
Kunde = selectedKunde
|
||||
};
|
||||
|
||||
@@ -49,9 +64,7 @@ namespace KanSan.ViewModel
|
||||
//unitOfWork.ProjekteRepository.Insert(newProjekt);
|
||||
unitOfWork.Commit();
|
||||
|
||||
List<Projekt> res = unitOfWork.ProjekteRepository.Get(x => x.GuidNr.Equals(guid)).ToList();
|
||||
if (res.Count < 1) throw new Exception("Der zuvor eingefügte Projekt konnte nicht in der Datenbank gefunden werden");
|
||||
return res.First();
|
||||
return newProjekt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user