Update Manager
continuous-integration/drone/push Build is failing Details

master
Louis DUFOUR 2 years ago
parent 21a5cfdbeb
commit 60b5c43571

@ -9,6 +9,7 @@
<ItemGroup>
<ProjectReference Include="..\Consoles\ConsoleTests\ConsoleTests.csproj" />
<ProjectReference Include="..\EFlib\EFlib.csproj" />
<ProjectReference Include="..\EFMapping\EFMapping.csproj" />
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>

@ -2,6 +2,7 @@
using Microsoft.EntityFrameworkCore;
using System.Linq;
using Model;
using EFMapping;
namespace EFManager
{
@ -15,22 +16,33 @@ namespace EFManager
public async Task<Champion?> AddItem(Champion? item)
{
if (item == null)
return null;
await parent.DbContext.Champions.AddAsync(item.toEF());
await parent.DbContext.SaveChangesAsync();
try
{
await parent.DbContext.Champions.AddAsync(item.toEF(parent.DbContext));
parent.DbContext.SaveChangesAsync();
}
catch (OperationCanceledException){}
catch(DbUpdateException){}
return item;
}
public async Task<bool> DeleteItem(Champion? item)
{
if (item == null)
try
{
var toDelete = parent.DbContext.Champions.Find(item.Name);
if (toDelete != null)
{
parent.DbContext.Champions.Remove(item.toEF(parent.DbContext));
parent.DbContext.SaveChangesAsync();
return true;
}
return false;
parent.DbContext.Champions.Remove(item.toEF());
await parent.DbContext.SaveChangesAsync();
return true;
}
catch (DbUpdateException)
{
return false;
}
}
public async Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)

Loading…
Cancel
Save