Repository erweitert

This commit is contained in:
Husky
2020-02-21 10:01:01 +01:00
parent 38e4d2aa6e
commit 842c42be58
3 changed files with 29 additions and 5 deletions

View File

@@ -7,8 +7,11 @@ namespace KanSan.Base.Interfaces
{ {
public interface IUnitOfWork public interface IUnitOfWork
{ {
IRepository<Projekt> BaustellenRepository { get; } IRepository<Projekt> ProjekteRepository { get; }
IRepository<Kunde> KundenRepository { get; } IRepository<Kunde> KundenRepository { get; }
IRepository<Baustelle> BaustelleRepository { get; }
IRepository<Sewer> KanaeleRepository { get; }
IRepository<SewerPoint> ObjekteRepository { get; }
void Commit(); void Commit();
} }
} }

View File

@@ -9,19 +9,22 @@ namespace KanSan.Base
public class UnitOfWork : IUnitOfWork public class UnitOfWork : IUnitOfWork
{ {
private KanSanContext _dbContext; private KanSanContext _dbContext;
private BaseRepository<Projekt> _baustellen; private BaseRepository<Projekt> _projekte;
private BaseRepository<Kunde> _kunden; private BaseRepository<Kunde> _kunden;
private BaseRepository<Baustelle> _baustellen;
private BaseRepository<Sewer> _kanaele;
private BaseRepository<SewerPoint> _objekte;
public UnitOfWork(KanSanContext dbContext) public UnitOfWork(KanSanContext dbContext)
{ {
_dbContext = dbContext; _dbContext = dbContext;
} }
public IRepository<Projekt> BaustellenRepository public IRepository<Projekt> ProjekteRepository
{ {
get get
{ {
return _baustellen ?? (_baustellen = new BaseRepository<Projekt>(_dbContext)); return _projekte ?? (_projekte = new BaseRepository<Projekt>(_dbContext));
} }
} }
@@ -33,6 +36,24 @@ namespace KanSan.Base
} }
} }
public IRepository<Baustelle> BaustelleRepository
{
get
{
return _baustellen ?? (_baustellen = new BaseRepository<Baustelle>(_dbContext));
}
}
public IRepository<Sewer> KanaeleRepository
{
get
{
return _kanaele ?? (_kanaele = new BaseRepository<Sewer>(_dbContext));
}
}
public IRepository<SewerPoint> ObjekteRepository => _objekte ?? (_objekte = new BaseRepository<SewerPoint>(_dbContext));
public void Commit() public void Commit()
{ {
_dbContext.SaveChanges(); _dbContext.SaveChanges();

View File

@@ -50,7 +50,7 @@ namespace KanSan.ViewModel
public ProjektViewModel() public ProjektViewModel()
{ {
_baustelle = unitOfWork.BaustellenRepository.Get().First(); _baustelle = unitOfWork.ProjekteRepository.Get().First();
ortTeil = _baustelle.Ort; ortTeil = _baustelle.Ort;
baustelleNummer = _baustelle.Projektnummer; baustelleNummer = _baustelle.Projektnummer;