Files
modernkeepass/WinAppCommon/ViewModels/Items/SettingsSecurityVm.cs
Geoffroy BONNEVILLE d211453553 WIP ViewModelLocator - Messenger and Recent issues
Refactoring
Code cleanup
2020-04-23 19:00:38 +02:00

37 lines
1.4 KiB
C#

using System.Threading.Tasks;
using GalaSoft.MvvmLight;
using MediatR;
using Messages;
using ModernKeePass.Application.Common.Interfaces;
using ModernKeePass.Application.Database.Commands.UpdateCredentials;
using ModernKeePass.Application.Database.Queries.GetDatabase;
namespace ModernKeePass.ViewModels.ListItems
{
public class SettingsSecurityVm: ViewModelBase
{
private readonly IMediator _mediator;
private readonly IResourceProxy _resource;
private readonly INotificationService _notification;
public SettingsSecurityVm(IMediator mediator, IResourceProxy resource, INotificationService notification)
{
_mediator = mediator;
_resource = resource;
_notification = notification;
MessengerInstance.Register<CredentialsSetMessage>(this, async message => await UpdateDatabaseCredentials(message));
}
public async Task UpdateDatabaseCredentials(CredentialsSetMessage message)
{
await _mediator.Send(new UpdateCredentialsCommand
{
KeyFilePath = message.KeyFilePath,
Password = message.Password
});
var database = await _mediator.Send(new GetDatabaseQuery());
_notification.Show(database.Name, _resource.GetResourceValue("CompositeKeyUpdated"));
}
}
}