WIP change to ids

This commit is contained in:
Geoffroy BONNEVILLE
2020-04-01 19:37:30 +02:00
parent 57be6bb917
commit b61a9652d1
24 changed files with 156 additions and 262 deletions

View File

@@ -8,7 +8,7 @@ namespace ModernKeePass.Application.Group.Commands.CreateGroup
{
public class CreateGroupCommand : IRequest<GroupVm>
{
public GroupVm ParentGroup { get; set; }
public string ParentGroupId { get; set; }
public string Name { get; set; }
public bool IsRecycleBin { get; set; }
@@ -27,10 +27,8 @@ namespace ModernKeePass.Application.Group.Commands.CreateGroup
{
if (!_database.IsOpen) throw new DatabaseClosedException();
var group = _database.CreateGroup(message.ParentGroup.Id, message.Name, message.IsRecycleBin);
var group = _database.CreateGroup(message.ParentGroupId, message.Name, message.IsRecycleBin);
var groupVm = _mapper.Map<GroupVm>(group);
groupVm.ParentGroup = message.ParentGroup;
message.ParentGroup.SubGroups.Add(groupVm);
return groupVm;
}
}

View File

@@ -1,31 +0,0 @@
using System.Threading.Tasks;
using MediatR;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Application.Entry.Models;
using ModernKeePass.Domain.Exceptions;
namespace ModernKeePass.Application.Group.Commands.DeleteEntry
{
public class DeleteEntryCommand : IRequest
{
public EntryVm Entry { get; set; }
public class DeleteEntryCommandHandler : IAsyncRequestHandler<DeleteEntryCommand>
{
private readonly IDatabaseProxy _database;
public DeleteEntryCommandHandler(IDatabaseProxy database)
{
_database = database;
}
public async Task Handle(DeleteEntryCommand message)
{
if (!_database.IsOpen) throw new DatabaseClosedException();
await _database.DeleteEntry(message.Entry.Id);
message.Entry = null;
}
}
}
}

View File

@@ -1,31 +0,0 @@
using System.Threading.Tasks;
using MediatR;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Application.Group.Models;
using ModernKeePass.Domain.Exceptions;
namespace ModernKeePass.Application.Group.Commands.DeleteGroup
{
public class DeleteGroupCommand : IRequest
{
public GroupVm Group { get; set; }
public class DeleteGroupCommandHandler : IAsyncRequestHandler<DeleteGroupCommand>
{
private readonly IDatabaseProxy _database;
public DeleteGroupCommandHandler(IDatabaseProxy database)
{
_database = database;
}
public async Task Handle(DeleteGroupCommand message)
{
if (!_database.IsOpen) throw new DatabaseClosedException();
await _database.DeleteGroup(message.Group.Id);
message.Group = null;
}
}
}
}

View File

@@ -11,6 +11,7 @@ namespace ModernKeePass.Application.Group.Commands.RemoveEntry
{
public GroupVm ParentGroup { get; set; }
public EntryVm Entry { get; set; }
public bool IsDelete { get; set; }
public class RemoveEntryCommandHandler : IAsyncRequestHandler<RemoveEntryCommand>
{
@@ -25,7 +26,7 @@ namespace ModernKeePass.Application.Group.Commands.RemoveEntry
{
if (!_database.IsOpen) throw new DatabaseClosedException();
await _database.RemoveEntry(message.ParentGroup.Id, message.Entry.Id);
await _database.RemoveEntry(message.ParentGroup.Id, message.Entry.Id, message.IsDelete);
message.ParentGroup.Entries.Remove(message.Entry);
}
}

View File

@@ -10,6 +10,7 @@ namespace ModernKeePass.Application.Group.Commands.RemoveGroup
{
public GroupVm ParentGroup { get; set; }
public GroupVm Group { get; set; }
public bool IsDelete { get; set; }
public class RemoveGroupCommandHandler : IAsyncRequestHandler<RemoveGroupCommand>
{
@@ -24,7 +25,7 @@ namespace ModernKeePass.Application.Group.Commands.RemoveGroup
{
if (!_database.IsOpen) throw new DatabaseClosedException();
await _database.RemoveGroup(message.ParentGroup.Id, message.Group.Id);
await _database.RemoveGroup(message.ParentGroup.Id, message.Group.Id, message.IsDelete);
message.ParentGroup.SubGroups.Remove(message.Group);
}
}