mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-04 16:10:16 -04:00

Auto rename additional field when it matches standard Treated all fields as new Field class Added the Is Protected property
31 lines
1004 B
C#
31 lines
1004 B
C#
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 bool IsProtected { get; set; } = true;
|
|
|
|
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, message.IsProtected);
|
|
}
|
|
}
|
|
}
|
|
} |