mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
Additional fields Add, Update and Delete work (too well)
SelectableListView works when programmatically setting selection
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Entry.Commands.UpsertField
|
||||
{
|
||||
public class UpsertFieldCommand : IRequest
|
||||
{
|
||||
public string EntryId { get; set; }
|
||||
public string FieldName { get; set; }
|
||||
public object FieldValue { get; set; }
|
||||
|
||||
public class UpsertFieldCommandHandler : IRequestHandler<UpsertFieldCommand>
|
||||
{
|
||||
private readonly IDatabaseProxy _database;
|
||||
|
||||
public UpsertFieldCommandHandler(IDatabaseProxy database)
|
||||
{
|
||||
_database = database;
|
||||
}
|
||||
|
||||
public void Handle(UpsertFieldCommand message)
|
||||
{
|
||||
if (!_database.IsOpen) throw new DatabaseClosedException();
|
||||
|
||||
_database.UpdateEntry(message.EntryId, message.FieldName, message.FieldValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
using FluentValidation;
|
||||
|
||||
namespace ModernKeePass.Application.Entry.Commands.UpsertField
|
||||
{
|
||||
public class UpsertFieldCommandValidator: AbstractValidator<UpsertFieldCommand>
|
||||
{
|
||||
public UpsertFieldCommandValidator()
|
||||
{
|
||||
RuleFor(v => v.EntryId)
|
||||
.NotNull()
|
||||
.NotEmpty();
|
||||
RuleFor(v => v.FieldName)
|
||||
.NotNull()
|
||||
.NotEmpty();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user