Kanalschaden werden richtig geparsed

This commit is contained in:
HuskyTeufel
2021-09-30 16:27:28 +02:00
parent 9da7090883
commit 98494be3cf
37 changed files with 576 additions and 136 deletions

View File

@@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -19,43 +20,35 @@ namespace DaSaSo.EntityFramework.Services.Common
}
public async Task<T> Create(T entity)
{
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
{
EntityEntry<T> createdEntity = await context.Set<T>().AddAsync(entity);
await context.SaveChangesAsync();
return createdEntity.Entity;
}
using DaSaSoDbContext context = _contextFactory.CreateDbContext();
EntityEntry<T> createdEntity = await context.Set<T>().AddAsync(entity);
await context.SaveChangesAsync();
return createdEntity.Entity;
}
public T CreateNonAsync(T entity)
{
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
{
EntityEntry<T> createdEntity = context.Set<T>().Add(entity);
context.SaveChanges();
return createdEntity.Entity;
}
using DaSaSoDbContext context = _contextFactory.CreateDbContext();
EntityEntry<T> createdEntity = context.Set<T>().Add(entity);
context.SaveChanges();
return createdEntity.Entity;
}
public async Task<bool> Delete(int id)
{
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
{
T entity = await context.Set<T>().FirstOrDefaultAsync((e) => e.Id == id);
context.Set<T>().Remove(entity);
await context.SaveChangesAsync();
return true;
}
using DaSaSoDbContext context = _contextFactory.CreateDbContext();
T entity = await context.Set<T>().FirstOrDefaultAsync((e) => e.Id == id);
context.Set<T>().Remove(entity);
await context.SaveChangesAsync();
return true;
}
public async Task<T> Update(int id, T entity)
{
using (DaSaSoDbContext context = _contextFactory.CreateDbContext())
{
entity.Id = id;
context.Set<T>().Update(entity);
await context.SaveChangesAsync();
return entity;
}
using DaSaSoDbContext context = _contextFactory.CreateDbContext();
entity.Id = id;
context.Set<T>().Update(entity);
await context.SaveChangesAsync();
return entity;
}
}
}