mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
More commands/queries
WIP on XAML EntryVm and GroupVm
This commit is contained in:
@@ -54,6 +54,9 @@
|
||||
<Compile Include="Common\Interfaces\ISettingsProxy.cs" />
|
||||
<Compile Include="Common\Mappings\IMapFrom.cs" />
|
||||
<Compile Include="Common\Mappings\MappingProfile.cs" />
|
||||
<Compile Include="Cryptography\Commands\SetCipher\SetCipherCommand.cs" />
|
||||
<Compile Include="Cryptography\Commands\SetCompression\SetCompressionCommand.cs" />
|
||||
<Compile Include="Cryptography\Commands\SetKeyDerivation\SetKeyDerivationCommand.cs" />
|
||||
<Compile Include="Cryptography\Models\CipherVm.cs" />
|
||||
<Compile Include="Cryptography\Models\KeyDerivationVm.cs" />
|
||||
<Compile Include="Cryptography\Queries\GetCiphers\GetCiphersQuery.cs" />
|
||||
@@ -71,6 +74,7 @@
|
||||
<Compile Include="Database\Queries\ReOpenDatabase\ReOpenDatabaseQuery.cs" />
|
||||
<Compile Include="DependencyInjection.cs" />
|
||||
<Compile Include="Entry\Commands\SetFieldValue\SetFieldValueCommand.cs" />
|
||||
<Compile Include="Entry\Commands\SetFieldValue\SetFieldValueCommandValidator.cs" />
|
||||
<Compile Include="Entry\Models\EntryVm.cs" />
|
||||
<Compile Include="Group\Commands\AddEntry\AddEntryCommand.cs" />
|
||||
<Compile Include="Group\Commands\AddGroup\AddGroupCommand.cs" />
|
||||
@@ -78,6 +82,7 @@
|
||||
<Compile Include="Group\Commands\CreateGroup\CreateGroupCommand.cs" />
|
||||
<Compile Include="Group\Commands\DeleteEntry\DeleteEntryCommand.cs" />
|
||||
<Compile Include="Group\Commands\DeleteGroup\DeleteGroupCommand.cs" />
|
||||
<Compile Include="Group\Commands\InsertEntry\InsertEntryCommand.cs" />
|
||||
<Compile Include="Group\Commands\RemoveEntry\RemoveEntryCommand.cs" />
|
||||
<Compile Include="Group\Commands\RemoveGroup\RemoveGroupCommand.cs" />
|
||||
<Compile Include="Group\Commands\SortEntries\SortEntriesCommand.cs" />
|
||||
@@ -102,9 +107,6 @@
|
||||
<Folder Include="Entry\Queries\GetEntry\" />
|
||||
<Folder Include="Group\Commands\UpdateGroup\" />
|
||||
<Folder Include="Group\Queries\GetGroup\" />
|
||||
<Folder Include="Parameters\Commands\SetCipher\" />
|
||||
<Folder Include="Parameters\Commands\SetCompression\" />
|
||||
<Folder Include="Parameters\Commands\SetKeyDerivation\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ModernKeePass.Domain\Domain.csproj">
|
||||
|
@@ -25,8 +25,9 @@ namespace ModernKeePass.Application.Common.Interfaces
|
||||
void CloseDatabase();
|
||||
|
||||
Task AddEntry(string parentGroupId, string entryId);
|
||||
Task InsertEntry(string parentGroupId, string entryId, int messageIndex);
|
||||
Task AddGroup(string parentGroupId, string groupId);
|
||||
void UpdateEntry(string entryId, string fieldName, string fieldValue);
|
||||
void UpdateEntry(string entryId, string fieldName, object fieldValue);
|
||||
void UpdateGroup(string groupId);
|
||||
Task RemoveEntry(string parentGroupId, string entryId);
|
||||
Task RemoveGroup(string parentGroupId, string groupId);
|
||||
|
@@ -0,0 +1,27 @@
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Cryptography.Commands.SetCipher
|
||||
{
|
||||
public class SetCipherCommand : IRequest
|
||||
{
|
||||
public string CipherId { get; set; }
|
||||
|
||||
public class SetCipherCommandHandler : IRequestHandler<SetCipherCommand>
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public SetCipherCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public void Handle(SetCipherCommand message)
|
||||
{
|
||||
if (_database.IsOpen) _database.CipherId = message.CipherId;
|
||||
else throw new DatabaseClosedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Cryptography.Commands.SetCompression
|
||||
{
|
||||
public class SetCompressionCommand : IRequest
|
||||
{
|
||||
public string Compression { get; set; }
|
||||
|
||||
public class SetCompressionCommandHandler : IRequestHandler<SetCompressionCommand>
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public SetCompressionCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public void Handle(SetCompressionCommand message)
|
||||
{
|
||||
if (_database.IsOpen) _database.Compression = message.Compression;
|
||||
else throw new DatabaseClosedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Cryptography.Commands.SetKeyDerivation
|
||||
{
|
||||
public class SetKeyDerivationCommand : IRequest
|
||||
{
|
||||
public string KeyDerivationId { get; set; }
|
||||
|
||||
public class SetKeyDerivationCommandHandler : IRequestHandler<SetKeyDerivationCommand>
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public SetKeyDerivationCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public void Handle(SetKeyDerivationCommand message)
|
||||
{
|
||||
if (_database.IsOpen) _database.KeyDerivationId = message.KeyDerivationId;
|
||||
else throw new DatabaseClosedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -14,7 +14,7 @@ namespace ModernKeePass.Application.Database.Commands.UpdateCredentials
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public UpdateCredentialsCommandHandler(IDatabaseProxy database, IMediator mediator)
|
||||
public UpdateCredentialsCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ namespace ModernKeePass.Application
|
||||
var assembly = typeof(DependencyInjection).GetTypeInfo().Assembly;
|
||||
services.AddAutoMapper(assembly);
|
||||
services.AddMediatR(assembly);
|
||||
//services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
|
||||
//services.AddValidatorsFromAssembly(assembly);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ namespace ModernKeePass.Application.Entry.Commands.SetFieldValue
|
||||
{
|
||||
public string EntryId { get; set; }
|
||||
public string FieldName { get; set; }
|
||||
public string FieldValue { get; set; }
|
||||
public object FieldValue { get; set; }
|
||||
|
||||
public class SetFieldValueCommandHandler : IRequestHandler<SetFieldValueCommand>
|
||||
{
|
||||
|
@@ -0,0 +1,17 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace ModernKeePass.Application.Entry.Commands.SetFieldValue
|
||||
{
|
||||
public class SetFieldValueCommandValidator: AbstractValidator<SetFieldValueCommand>
|
||||
{
|
||||
public SetFieldValueCommandValidator()
|
||||
{
|
||||
RuleFor(v => v.EntryId)
|
||||
.NotNull()
|
||||
.NotEmpty();
|
||||
RuleFor(v => v.FieldName)
|
||||
.NotNull()
|
||||
.NotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
@@ -17,7 +17,7 @@ namespace ModernKeePass.Application.Entry.Models
|
||||
public string Notes { get; set; }
|
||||
public Uri Url { get; set; }
|
||||
public Dictionary<string, string> AdditionalFields { get; set; }
|
||||
public IEnumerable<EntryEntity> History { get; set; }
|
||||
public IEnumerable<EntryVm> History { get; set; }
|
||||
public Icon Icon { get; set; }
|
||||
public Color ForegroundColor { get; set; }
|
||||
public Color BackgroundColor { get; set; }
|
||||
|
@@ -0,0 +1,34 @@
|
||||
using System.Threading.Tasks;
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Entry.Models;
|
||||
using ModernKeePass.Application.Group.Models;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Group.Commands.InsertEntry
|
||||
{
|
||||
public class InsertEntryCommand : IRequest
|
||||
{
|
||||
public GroupVm ParentGroup { get; set; }
|
||||
public EntryVm Entry { get; set; }
|
||||
public int Index { get; set; }
|
||||
|
||||
public class InsertEntryCommandHandler : IAsyncRequestHandler<InsertEntryCommand>
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public InsertEntryCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public async Task Handle(InsertEntryCommand message)
|
||||
{
|
||||
if (!_database.IsOpen) throw new DatabaseClosedException();
|
||||
|
||||
await _database.InsertEntry(message.ParentGroup.Id, message.Entry.Id, message.Index);
|
||||
message.ParentGroup.Entries.Insert(message.Index, message.Entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user