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> <ItemGroup>
<ProjectReference Include="..\Consoles\ConsoleTests\ConsoleTests.csproj" /> <ProjectReference Include="..\Consoles\ConsoleTests\ConsoleTests.csproj" />
<ProjectReference Include="..\EFlib\EFlib.csproj" /> <ProjectReference Include="..\EFlib\EFlib.csproj" />
<ProjectReference Include="..\EFMapping\EFMapping.csproj" />
<ProjectReference Include="..\Model\Model.csproj" /> <ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup> </ItemGroup>

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

Loading…
Cancel
Save