Haltungübersicht angefangen
This commit is contained in:
70
SewerStammGen.EntityFramework/Services/HaltungDataService.cs
Normal file
70
SewerStammGen.EntityFramework/Services/HaltungDataService.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using SewerStammGen.EntityFramework.Services.Common;
|
||||
using SewerStammGen.Shared.Contracts;
|
||||
using Shared.Domain;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewerStammGen.EntityFramework.Services
|
||||
{
|
||||
public class HaltungDataService : IHaltungDataService
|
||||
{
|
||||
private readonly SewerStammGenDbContextFactory _contextFactory;
|
||||
private readonly NonQueryDataService<Kanal> _nonQueryDataService;
|
||||
|
||||
public HaltungDataService(SewerStammGenDbContextFactory contextFactory)
|
||||
{
|
||||
_contextFactory = contextFactory;
|
||||
_nonQueryDataService = new NonQueryDataService<Kanal>(contextFactory);
|
||||
}
|
||||
public async Task<Kanal> Create(Kanal entity)
|
||||
{
|
||||
return await _nonQueryDataService.Create(entity);
|
||||
}
|
||||
|
||||
public Kanal CreateNonAsync(Kanal entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<bool> Delete(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<Kanal> Get(int id)
|
||||
{
|
||||
using (SewerStammGenDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
Kanal entity = await context.Set<Kanal>()
|
||||
.Include("StartSchacht")
|
||||
.Include("EndSchacht")
|
||||
.Include("Projekt")
|
||||
.FirstOrDefaultAsync((e) => e.Id == id);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Kanal>> GetAll(int projektID)
|
||||
{
|
||||
using (SewerStammGenDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
IEnumerable<Kanal> entities = await context.Set<Kanal>().Where(x => x.Projekt.Id.Equals(projektID)).ToListAsync();
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<IEnumerable<Kanal>> GetAll()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<Kanal> Update(int id, Kanal entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user