Objectliste angefangen
This commit is contained in:
59
DaSaSo.EntityFramework/Services/SewerObjectDataService.cs
Normal file
59
DaSaSo.EntityFramework/Services/SewerObjectDataService.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using DaSaSo.Domain.Model;
|
||||
using DaSaSo.Domain.Services;
|
||||
using DaSaSo.EntityFramework.Services.Common;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DaSaSo.EntityFramework.Services
|
||||
{
|
||||
public class SewerObjectDataService : IDataService<SewerObject>
|
||||
{
|
||||
private readonly DaSaSoDbContextFactory _contextFactory;
|
||||
private readonly NonQueryDataService<SewerObject> _nonQueryDataService;
|
||||
|
||||
public SewerObjectDataService(DaSaSoDbContextFactory contextFactory)
|
||||
{
|
||||
this._contextFactory = contextFactory;
|
||||
_nonQueryDataService = new NonQueryDataService<SewerObject>(contextFactory);
|
||||
}
|
||||
|
||||
public async Task<SewerObject> Create(SewerObject entity)
|
||||
{
|
||||
return await _nonQueryDataService.Create(entity);
|
||||
}
|
||||
|
||||
public async Task<bool> Delete(int id)
|
||||
{
|
||||
return await _nonQueryDataService.Delete(id);
|
||||
}
|
||||
|
||||
public Task<SewerObject> Get(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<IEnumerable<SewerObject>> GetAll()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<SewerObject>> GetAllByBuildingsite(Buildingsite buildingsite)
|
||||
{
|
||||
int id = buildingsite.Id;
|
||||
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
IEnumerable<SewerObject> entities = await context.SewerObjects.Where(x => x.BuildingSite.Id == id).ToListAsync();
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<SewerObject> Update(int id, SewerObject entity)
|
||||
{
|
||||
return await _nonQueryDataService.Update(id, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user