Leitungen können nun bearbeitet werden
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0-rc.1.21452.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0-rc.1.21452.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0-rc.1.21452.10">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
||||
@@ -8,28 +8,26 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace DaSaSo.EntityFramework
|
||||
{
|
||||
public class DaSaSoDbContextFactory : IDesignTimeDbContextFactory<DaSaSoDbContext>
|
||||
public class DaSaSoDbContextFactory
|
||||
{
|
||||
private readonly string _connectionString;
|
||||
private readonly Action<DbContextOptionsBuilder> _configureDbContext;
|
||||
|
||||
public DaSaSoDbContextFactory()
|
||||
public DaSaSoDbContextFactory(Action<DbContextOptionsBuilder> configureDbContext)
|
||||
{
|
||||
|
||||
}
|
||||
public DaSaSoDbContextFactory(string connectionString)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_configureDbContext = configureDbContext;
|
||||
}
|
||||
|
||||
|
||||
public DaSaSoDbContext CreateDbContext()
|
||||
{
|
||||
var options = new DbContextOptionsBuilder<DaSaSoDbContext>();
|
||||
DbContextOptionsBuilder<DaSaSoDbContext>? options = new DbContextOptionsBuilder<DaSaSoDbContext>();
|
||||
_configureDbContext(options);
|
||||
//_connectionString = "Host = localhost; Database = dasaso; Username = kansan; Password = kansan";
|
||||
options.UseNpgsql(_connectionString);
|
||||
DaSaSoDbContext result = new DaSaSoDbContext(options.Options);
|
||||
return result;
|
||||
//options.UseNpgsql(_connectionString);
|
||||
//DaSaSoDbContext result = new DaSaSoDbContext(options.Options);
|
||||
return new DaSaSoDbContext(options.Options);
|
||||
}
|
||||
|
||||
/*
|
||||
public DaSaSoDbContext CreateDbContext(string[]? args = null)
|
||||
{
|
||||
var options = new DbContextOptionsBuilder<DaSaSoDbContext>();
|
||||
@@ -37,5 +35,6 @@ namespace DaSaSo.EntityFramework
|
||||
DaSaSoDbContext result = new DaSaSoDbContext(options.Options);
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,14 @@ namespace DaSaSo.EntityFramework.Services
|
||||
return await _nonQueryDataService.Delete(id);
|
||||
}
|
||||
|
||||
public Task<Buildingsite> Get(int id)
|
||||
public async Task<Buildingsite> Get(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
Buildingsite entity = await context.Buildingsites.FirstOrDefaultAsync((e) => e.Id == id);
|
||||
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<IEnumerable<Buildingsite>> GetAll()
|
||||
|
||||
@@ -31,9 +31,14 @@ namespace DaSaSo.EntityFramework.Services
|
||||
return await _nonQueryDataService.Delete(id);
|
||||
}
|
||||
|
||||
public Task<Project> Get(int id)
|
||||
public async Task<Project> Get(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
|
||||
{
|
||||
Project entity = await context.Projects.FirstOrDefaultAsync((e) => e.Id == id);
|
||||
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Project>> GetAllByClient(Client client)
|
||||
|
||||
53
DaSaSo.EntityFramework/Services/SewerpointDataService.cs
Normal file
53
DaSaSo.EntityFramework/Services/SewerpointDataService.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using DaSaSo.Domain.Model;
|
||||
using DaSaSo.Domain.Services;
|
||||
using DaSaSo.EntityFramework.Services.Common;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DaSaSo.EntityFramework.Services
|
||||
{
|
||||
public class SewerpointDataService : IDataService<SewerPoint>
|
||||
{
|
||||
private readonly DaSaSoDbContextFactory _contextFactory;
|
||||
private readonly NonQueryDataService<SewerPoint> _nonQueryDataService;
|
||||
|
||||
public SewerpointDataService(DaSaSoDbContextFactory contextFactory)
|
||||
{
|
||||
_contextFactory = contextFactory;
|
||||
_nonQueryDataService = new NonQueryDataService<SewerPoint>(contextFactory);
|
||||
}
|
||||
|
||||
public async Task<SewerPoint> Create(SewerPoint entity)
|
||||
{
|
||||
return await _nonQueryDataService.Create(entity);
|
||||
}
|
||||
|
||||
public SewerPoint CreateNonAsync(SewerPoint entity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<bool> Delete(int id)
|
||||
{
|
||||
return await _nonQueryDataService.Delete(id);
|
||||
}
|
||||
|
||||
public Task<SewerPoint> Get(int id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<IEnumerable<SewerPoint>> GetAll()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<SewerPoint> Update(int id, SewerPoint entity)
|
||||
{
|
||||
return await _nonQueryDataService.Update(id, entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user