More edge cases
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
using Bitvault.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Toolkit.Foundation;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
namespace Bitvault;
|
||||
|
||||
public class FavouriteItemHandler(IValueStore<Item> valueStore,
|
||||
IDbContextFactory<ContainerDbContext> dbContextFactory) :
|
||||
IMediator mediator) :
|
||||
INotificationHandler<FavouriteEventArgs<Item>>
|
||||
{
|
||||
public async Task Handle(FavouriteEventArgs<Item> args)
|
||||
@@ -14,16 +12,8 @@ public class FavouriteItemHandler(IValueStore<Item> valueStore,
|
||||
{
|
||||
if (valueStore.Value is Item item)
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
using ContainerDbContext context = await dbContextFactory.CreateDbContextAsync();
|
||||
|
||||
if (await context.FindAsync<ItemEntry>(item.Id) is ItemEntry result)
|
||||
{
|
||||
result.State = 1;
|
||||
await context.SaveChangesAsync();
|
||||
}
|
||||
});
|
||||
await mediator.Handle<UpdateEventArgs<(Guid, int)>, bool>(new UpdateEventArgs<(Guid,
|
||||
int)>((item.Id, 1)));
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
||||
Reference in New Issue
Block a user