Most services are implemented as command/queries

Code cleanup
This commit is contained in:
Geoffroy BONNEVILLE
2020-03-26 19:04:51 +01:00
parent 903e7649e4
commit 22072bb2fe
46 changed files with 567 additions and 390 deletions

View File

@@ -0,0 +1,31 @@
using MediatR;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Domain.Dtos;
namespace ModernKeePass.Application.Recent.Commands.AddRecent
{
public class AddRecentCommand: IRequest
{
public string Name { get; set; }
public string Path { get; set; }
public class AddRecentCommandHandler: IRequestHandler<AddRecentCommand>
{
private readonly IRecentProxy _recent;
public AddRecentCommandHandler(IRecentProxy recent)
{
_recent = recent;
}
public void Handle(AddRecentCommand message)
{
_recent.Add(new FileInfo
{
Name = message.Name,
Path = message.Path
});
}
}
}
}

View File

@@ -0,0 +1,23 @@
using MediatR;
using ModernKeePass.Application.Common.Interfaces;
namespace ModernKeePass.Application.Recent.Commands.ClearAllRecent
{
public class ClearAllRecentCommand : IRequest
{
public class ClearAllRecentCommandHandler : IRequestHandler<ClearAllRecentCommand>
{
private readonly IRecentProxy _recent;
public ClearAllRecentCommandHandler(IRecentProxy recent)
{
_recent = recent;
}
public void Handle(ClearAllRecentCommand message)
{
_recent.ClearAll();
}
}
}
}