mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 23:50:18 -04:00
33 lines
1011 B
C#
33 lines
1011 B
C#
using System.Threading.Tasks;
|
|
using Windows.Storage;
|
|
using Windows.Storage.AccessCache;
|
|
using MediatR;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using ModernKeePass.Application.Database.Commands.CloseDatabase;
|
|
using ModernKeePass.Application.Database.Commands.SaveDatabase;
|
|
|
|
namespace ModernKeePass.ViewModels
|
|
{
|
|
public class SaveVm
|
|
{
|
|
private readonly IMediator _mediator;
|
|
public SaveVm() : this(App.Services.GetService<IMediator>()) { }
|
|
|
|
public SaveVm(IMediator mediator)
|
|
{
|
|
_mediator = mediator;
|
|
}
|
|
|
|
public async Task Save(bool close = true)
|
|
{
|
|
await _mediator.Send(new SaveDatabaseCommand());
|
|
if (close) await _mediator.Send(new CloseDatabaseCommand());
|
|
}
|
|
|
|
public async Task Save(StorageFile file)
|
|
{
|
|
var token = StorageApplicationPermissions.FutureAccessList.Add(file);
|
|
await _mediator.Send(new SaveDatabaseCommand { FilePath = token });
|
|
}
|
|
}
|
|
} |