diff --git a/ModernKeePass.Application/Application.csproj b/ModernKeePass.Application/Application.csproj
index 33a1a6e..32e72df 100644
--- a/ModernKeePass.Application/Application.csproj
+++ b/ModernKeePass.Application/Application.csproj
@@ -43,14 +43,11 @@
-
-
-
@@ -91,18 +88,9 @@
-
-
-
-
-
-
-
-
-
diff --git a/ModernKeePass.Application/Common/Interfaces/IDatabaseProxy.cs b/ModernKeePass.Application/Common/Interfaces/IDatabaseProxy.cs
index 730bd3e..4beb4a7 100644
--- a/ModernKeePass.Application/Common/Interfaces/IDatabaseProxy.cs
+++ b/ModernKeePass.Application/Common/Interfaces/IDatabaseProxy.cs
@@ -10,7 +10,7 @@ namespace ModernKeePass.Application.Common.Interfaces
string Name { get; }
GroupEntity RootGroup { get; }
- string RecycleBinId { get; set; }
+ GroupEntity RecycleBin { get; set; }
string CipherId { get; set; }
string KeyDerivationId { get; set; }
string Compression { get; set; }
@@ -21,6 +21,7 @@ namespace ModernKeePass.Application.Common.Interfaces
Task Create(FileInfo fileInfo, Credentials credentials);
Task SaveDatabase();
Task SaveDatabase(string filePath);
+ void SetRecycleBin(string id);
Task UpdateCredentials(Credentials credentials);
void CloseDatabase();
diff --git a/ModernKeePass.Application/Common/Interfaces/IHasSelectableObject.cs b/ModernKeePass.Application/Common/Interfaces/IHasSelectableObject.cs
deleted file mode 100644
index f2fd247..0000000
--- a/ModernKeePass.Application/Common/Interfaces/IHasSelectableObject.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace ModernKeePass.Application.Common.Interfaces
-{
- public interface IHasSelectableObject
- {
- ISelectableModel SelectedItem { get; set; }
- }
-}
diff --git a/ModernKeePass.Application/Common/Interfaces/IIsEnabled.cs b/ModernKeePass.Application/Common/Interfaces/IIsEnabled.cs
deleted file mode 100644
index 1abc45a..0000000
--- a/ModernKeePass.Application/Common/Interfaces/IIsEnabled.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace ModernKeePass.Application.Common.Interfaces
-{
- public interface IIsEnabled
- {
- bool IsEnabled { get; }
- }
-}
diff --git a/ModernKeePass.Application/Common/Interfaces/ISelectableModel.cs b/ModernKeePass.Application/Common/Interfaces/ISelectableModel.cs
deleted file mode 100644
index 1102637..0000000
--- a/ModernKeePass.Application/Common/Interfaces/ISelectableModel.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace ModernKeePass.Application.Common.Interfaces
-{
- public interface ISelectableModel
- {
- bool IsSelected { get; set; }
- }
-}
\ No newline at end of file
diff --git a/ModernKeePass.Application/Database/Models/DatabaseVm.cs b/ModernKeePass.Application/Database/Models/DatabaseVm.cs
index b3efd5d..2de796d 100644
--- a/ModernKeePass.Application/Database/Models/DatabaseVm.cs
+++ b/ModernKeePass.Application/Database/Models/DatabaseVm.cs
@@ -7,7 +7,7 @@ namespace ModernKeePass.Application.Database.Models
public bool IsOpen { get; set; }
public string Name { get; set; }
public GroupVm RootGroup { get; set; }
- public string RecycleBinId { get; set; }
+ public GroupVm RecycleBin { get; set; }
public bool IsRecycleBinEnabled { get; set; }
public string Compression { get; set; }
public string CipherId { get; set; }
diff --git a/ModernKeePass.Application/Database/Queries/GetDatabase/GetDatabaseQuery.cs b/ModernKeePass.Application/Database/Queries/GetDatabase/GetDatabaseQuery.cs
index 26d0c08..51d0beb 100644
--- a/ModernKeePass.Application/Database/Queries/GetDatabase/GetDatabaseQuery.cs
+++ b/ModernKeePass.Application/Database/Queries/GetDatabase/GetDatabaseQuery.cs
@@ -27,7 +27,7 @@ namespace ModernKeePass.Application.Database.Queries.GetDatabase
Name = _databaseProxy.Name,
RootGroup = _mapper.Map(_databaseProxy.RootGroup),
IsRecycleBinEnabled = _databaseProxy.IsRecycleBinEnabled,
- RecycleBinId = _databaseProxy.RecycleBinId,
+ RecycleBin = _mapper.Map(_databaseProxy.RecycleBin),
Compression = _databaseProxy.Compression,
CipherId = _databaseProxy.CipherId,
KeyDerivationId = _databaseProxy.CipherId
diff --git a/ModernKeePass.Application/Group/Models/GroupVm.cs b/ModernKeePass.Application/Group/Models/GroupVm.cs
index 359fbb0..3dac9b2 100644
--- a/ModernKeePass.Application/Group/Models/GroupVm.cs
+++ b/ModernKeePass.Application/Group/Models/GroupVm.cs
@@ -13,6 +13,7 @@ namespace ModernKeePass.Application.Group.Models
public string Id { get; set; }
public string Title { get; set; }
public Icon Icon { get; set; }
+ public GroupVm ParentGroup { get; set; }
public List SubGroups { get; set; } = new List();
public List Entries { get; set; } = new List();
@@ -22,6 +23,7 @@ namespace ModernKeePass.Application.Group.Models
.ForMember(d => d.Id, opts => opts.MapFrom(s => s.Id))
.ForMember(d => d.Title, opts => opts.MapFrom(s => s.Name))
.ForMember(d => d.Icon, opts => opts.MapFrom(s => s.Icon))
+ .ForMember(d => d.ParentGroup, opts => opts.MapFrom(s => s.Parent))
.ForMember(d => d.Entries, opts => opts.MapFrom(s => s.Entries.OrderBy(e => e.Name)))
.ForMember(d => d.SubGroups, opts => opts.MapFrom(s => s.SubGroups));
}
diff --git a/ModernKeePass.Application/Parameters/Commands/SetRecycleBin/SetRecycleBinCommand.cs b/ModernKeePass.Application/Parameters/Commands/SetRecycleBin/SetRecycleBinCommand.cs
index 2725adb..bb7e0f3 100644
--- a/ModernKeePass.Application/Parameters/Commands/SetRecycleBin/SetRecycleBinCommand.cs
+++ b/ModernKeePass.Application/Parameters/Commands/SetRecycleBin/SetRecycleBinCommand.cs
@@ -1,12 +1,13 @@
using MediatR;
using ModernKeePass.Application.Common.Interfaces;
+using ModernKeePass.Application.Group.Models;
using ModernKeePass.Domain.Exceptions;
namespace ModernKeePass.Application.Parameters.Commands.SetRecycleBin
{
public class SetRecycleBinCommand : IRequest
{
- public string RecycleBinId { get; set; }
+ public GroupVm RecycleBin { get; set; }
public class SetRecycleBinCommandHandler : IRequestHandler
{
@@ -19,7 +20,7 @@ namespace ModernKeePass.Application.Parameters.Commands.SetRecycleBin
public void Handle(SetRecycleBinCommand message)
{
- if (_database.IsOpen) _database.RecycleBinId = message.RecycleBinId;
+ if (_database.IsOpen) _database.SetRecycleBin(message.RecycleBin.Id);
else throw new DatabaseClosedException();
}
}
diff --git a/ModernKeePass.Application/Recent/Commands/AddRecent/AddRecentCommand.cs b/ModernKeePass.Application/Recent/Commands/AddRecent/AddRecentCommand.cs
deleted file mode 100644
index 326f3c8..0000000
--- a/ModernKeePass.Application/Recent/Commands/AddRecent/AddRecentCommand.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using MediatR;
-using ModernKeePass.Application.Common.Interfaces;
-using ModernKeePass.Domain.Dtos;
-
-namespace ModernKeePass.Application.Recent.Commands.AddRecent
-{
- public class AddRecentCommand: IRequest
- {
- public string Name { get; set; }
- public string Path { get; set; }
-
- public class AddRecentCommandHandler: IRequestHandler
- {
- private readonly IRecentProxy _recent;
-
- public AddRecentCommandHandler(IRecentProxy recent)
- {
- _recent = recent;
- }
-
- public void Handle(AddRecentCommand message)
- {
- _recent.Add(new FileInfo
- {
- Name = message.Name,
- Path = message.Path
- });
- }
- }
- }
-}
\ No newline at end of file
diff --git a/ModernKeePass.Application/Recent/Commands/ClearAllRecent/ClearAllRecentCommand.cs b/ModernKeePass.Application/Recent/Commands/ClearAllRecent/ClearAllRecentCommand.cs
deleted file mode 100644
index 9181e62..0000000
--- a/ModernKeePass.Application/Recent/Commands/ClearAllRecent/ClearAllRecentCommand.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using MediatR;
-using ModernKeePass.Application.Common.Interfaces;
-
-namespace ModernKeePass.Application.Recent.Commands.ClearAllRecent
-{
- public class ClearAllRecentCommand : IRequest
- {
- public class ClearAllRecentCommandHandler : IRequestHandler
- {
- private readonly IRecentProxy _recent;
-
- public ClearAllRecentCommandHandler(IRecentProxy recent)
- {
- _recent = recent;
- }
-
- public void Handle(ClearAllRecentCommand message)
- {
- _recent.ClearAll();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/ModernKeePass.Application/Recent/Models/RecentVm.cs b/ModernKeePass.Application/Recent/Models/RecentVm.cs
deleted file mode 100644
index 1abf3c1..0000000
--- a/ModernKeePass.Application/Recent/Models/RecentVm.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using AutoMapper;
-using ModernKeePass.Application.Common.Mappings;
-using ModernKeePass.Domain.Dtos;
-
-namespace ModernKeePass.Application.Recent.Models
-{
- public class RecentVm: IMapFrom
- {
- public string Name { get; set; }
- public string Path { get; set; }
- public void Mapping(Profile profile)
- {
- profile.CreateMap()
- .ForMember(d => d.Name, opts => opts.MapFrom(s => s.Name))
- .ForMember(d => d.Path, opts => opts.MapFrom(s => s.Path));
- }
- }
-}
\ No newline at end of file
diff --git a/ModernKeePass.Application/Recent/Queries/GetAllRecent/GetAllRecentQuery.cs b/ModernKeePass.Application/Recent/Queries/GetAllRecent/GetAllRecentQuery.cs
deleted file mode 100644
index cf55224..0000000
--- a/ModernKeePass.Application/Recent/Queries/GetAllRecent/GetAllRecentQuery.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using AutoMapper;
-using MediatR;
-using ModernKeePass.Application.Common.Interfaces;
-using ModernKeePass.Application.Recent.Models;
-
-namespace ModernKeePass.Application.Recent.Queries.GetAllRecent
-{
- public class GetAllRecentQuery : IRequest>
- {
- public class GetAllRecentQueryHandler : IAsyncRequestHandler>
- {
- private readonly IRecentProxy _recent;
- private readonly IMapper _mapper;
-
- public GetAllRecentQueryHandler(IRecentProxy recent, IMapper mapper)
- {
- _recent = recent;
- _mapper = mapper;
- }
-
- public async Task> Handle(GetAllRecentQuery message)
- {
- var fileInfo = await _recent.GetAll();
- return _mapper.Map>(fileInfo);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/ModernKeePass.Application/Recent/Queries/GetRecent/GetRecentQuery.cs b/ModernKeePass.Application/Recent/Queries/GetRecent/GetRecentQuery.cs
deleted file mode 100644
index 7e20b99..0000000
--- a/ModernKeePass.Application/Recent/Queries/GetRecent/GetRecentQuery.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System.Threading.Tasks;
-using AutoMapper;
-using MediatR;
-using ModernKeePass.Application.Common.Interfaces;
-using ModernKeePass.Application.Recent.Models;
-
-namespace ModernKeePass.Application.Recent.Queries.GetRecent
-{
- public class GetRecentQuery : IRequest
- {
- public string Token { get; set; }
-
- public class GetRecentQueryHandler : IAsyncRequestHandler
- {
- private readonly IRecentProxy _recent;
- private readonly IMapper _mapper;
-
- public GetRecentQueryHandler(IRecentProxy recent, IMapper mapper)
- {
- _recent = recent;
- _mapper = mapper;
- }
-
- public async Task Handle(GetRecentQuery message)
- {
- var fileInfo = await _recent.Get(message.Token);
- return _mapper.Map(fileInfo);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/ModernKeePass.Application/Recent/Queries/HasRecent/HasRecentQuery.cs b/ModernKeePass.Application/Recent/Queries/HasRecent/HasRecentQuery.cs
deleted file mode 100644
index a939452..0000000
--- a/ModernKeePass.Application/Recent/Queries/HasRecent/HasRecentQuery.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using MediatR;
-using ModernKeePass.Application.Common.Interfaces;
-
-namespace ModernKeePass.Application.Recent.Queries.HasRecent
-{
- public class HasRecentQuery : IRequest
- {
- public class HasRecentQueryHandler : IRequestHandler
- {
- private readonly IRecentProxy _recent;
-
- public HasRecentQueryHandler(IRecentProxy recent)
- {
- _recent = recent;
- }
-
- public bool Handle(HasRecentQuery message)
- {
- return _recent.EntryCount > 0;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/ModernKeePass.Application/Resources/Queries/GetResourceQuery.cs b/ModernKeePass.Application/Resources/Queries/GetResourceQuery.cs
deleted file mode 100644
index fde20ef..0000000
--- a/ModernKeePass.Application/Resources/Queries/GetResourceQuery.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using MediatR;
-using ModernKeePass.Application.Common.Interfaces;
-
-namespace ModernKeePass.Application.Resources.Queries
-{
- public class GetResourceQuery: IRequest
- {
- public string Key { get; set; }
- public class GetResourceQueryHandler: IRequestHandler
- {
- private readonly IResourceProxy _resourceProxy;
-
- public GetResourceQueryHandler(IResourceProxy resourceProxy)
- {
- _resourceProxy = resourceProxy;
- }
- public string Handle(GetResourceQuery message)
- {
- return _resourceProxy.GetResourceValue(message.Key);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/ModernKeePass.Application/Settings/Commands/PutSettingCommand.cs b/ModernKeePass.Application/Settings/Commands/PutSettingCommand.cs
deleted file mode 100644
index b21e833..0000000
--- a/ModernKeePass.Application/Settings/Commands/PutSettingCommand.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using MediatR;
-using ModernKeePass.Application.Common.Interfaces;
-
-namespace ModernKeePass.Application.Settings.Commands
-{
- public class PutSettingCommand : IRequest
- {
- public string Key { get; set; }
- public T value { get; set; }
-
- public class PutSettingCommandHandler : IRequestHandler>
- {
- private readonly ISettingsProxy _settingsProxy;
-
- public PutSettingCommandHandler(ISettingsProxy settingsProxy)
- {
- _settingsProxy = settingsProxy;
- }
- public void Handle(PutSettingCommand message)
- {
- _settingsProxy.PutSetting(message.Key, message.value);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/ModernKeePass.Application/Settings/Queries/GetSettingQuery.cs b/ModernKeePass.Application/Settings/Queries/GetSettingQuery.cs
deleted file mode 100644
index 0968f72..0000000
--- a/ModernKeePass.Application/Settings/Queries/GetSettingQuery.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using MediatR;
-using ModernKeePass.Application.Common.Interfaces;
-
-namespace ModernKeePass.Application.Settings.Queries
-{
- public class GetSettingQuery : IRequest
- {
- public string Key { get; set; }
-
- public class GetSettingQueryHandler : IRequestHandler, T>
- {
- private readonly ISettingsProxy _settingsProxy;
-
- public GetSettingQueryHandler(ISettingsProxy settingsProxy)
- {
- _settingsProxy = settingsProxy;
- }
- public T Handle(GetSettingQuery message)
- {
- return _settingsProxy.GetSetting(message.Key);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/ModernKeePass.Domain/Domain.csproj b/ModernKeePass.Domain/Domain.csproj
index b933f71..45dc551 100644
--- a/ModernKeePass.Domain/Domain.csproj
+++ b/ModernKeePass.Domain/Domain.csproj
@@ -55,6 +55,9 @@
+
+
+
diff --git a/ModernKeePass.Domain/Entities/BaseEntity.cs b/ModernKeePass.Domain/Entities/BaseEntity.cs
index 59a19e6..367dd62 100644
--- a/ModernKeePass.Domain/Entities/BaseEntity.cs
+++ b/ModernKeePass.Domain/Entities/BaseEntity.cs
@@ -6,6 +6,7 @@ namespace ModernKeePass.Domain.Entities
{
public string Id { get; set; }
public string Name { get; set; }
+ public GroupEntity Parent { get; set; }
public DateTimeOffset LastModificationDate { get; set; }
}
}
\ No newline at end of file
diff --git a/ModernKeePass/Interfaces/IHasSelectableObject.cs b/ModernKeePass.Domain/Interfaces/IHasSelectableObject.cs
similarity index 70%
rename from ModernKeePass/Interfaces/IHasSelectableObject.cs
rename to ModernKeePass.Domain/Interfaces/IHasSelectableObject.cs
index 038cb05..d0ad04a 100644
--- a/ModernKeePass/Interfaces/IHasSelectableObject.cs
+++ b/ModernKeePass.Domain/Interfaces/IHasSelectableObject.cs
@@ -1,4 +1,4 @@
-namespace ModernKeePass.Interfaces
+namespace ModernKeePass.Domain.Interfaces
{
public interface IHasSelectableObject
{
diff --git a/ModernKeePass/Interfaces/IIsEnabled.cs b/ModernKeePass.Domain/Interfaces/IIsEnabled.cs
similarity index 64%
rename from ModernKeePass/Interfaces/IIsEnabled.cs
rename to ModernKeePass.Domain/Interfaces/IIsEnabled.cs
index cfed3ab..28e8c61 100644
--- a/ModernKeePass/Interfaces/IIsEnabled.cs
+++ b/ModernKeePass.Domain/Interfaces/IIsEnabled.cs
@@ -1,4 +1,4 @@
-namespace ModernKeePass.Interfaces
+namespace ModernKeePass.Domain.Interfaces
{
public interface IIsEnabled
{
diff --git a/ModernKeePass/Interfaces/ISelectableModel.cs b/ModernKeePass.Domain/Interfaces/ISelectableModel.cs
similarity index 66%
rename from ModernKeePass/Interfaces/ISelectableModel.cs
rename to ModernKeePass.Domain/Interfaces/ISelectableModel.cs
index b1382cd..7058958 100644
--- a/ModernKeePass/Interfaces/ISelectableModel.cs
+++ b/ModernKeePass.Domain/Interfaces/ISelectableModel.cs
@@ -1,4 +1,4 @@
-namespace ModernKeePass.Interfaces
+namespace ModernKeePass.Domain.Interfaces
{
public interface ISelectableModel
{
diff --git a/ModernKeePass.Infrastructure/DependencyInjection.cs b/ModernKeePass.Infrastructure/DependencyInjection.cs
index 9c2110d..50d63a7 100644
--- a/ModernKeePass.Infrastructure/DependencyInjection.cs
+++ b/ModernKeePass.Infrastructure/DependencyInjection.cs
@@ -2,6 +2,8 @@
using AutoMapper;
using Microsoft.Extensions.DependencyInjection;
using ModernKeePass.Application.Common.Interfaces;
+using ModernKeePass.Domain.Interfaces;
+using ModernKeePass.Infrastructure.Common;
using ModernKeePass.Infrastructure.KeePass;
using ModernKeePass.Infrastructure.UWP;
@@ -17,10 +19,11 @@ namespace ModernKeePass.Infrastructure
services.AddSingleton(typeof(IDatabaseProxy), typeof(KeePassDatabaseClient));
services.AddTransient(typeof(ICryptographyClient), typeof(KeePassCryptographyClient));
services.AddTransient(typeof(IPasswordProxy), typeof(KeePassPasswordClient));
- services.AddTransient(typeof(IResourceProxy), typeof(UwpResourceClient));
+ /*services.AddTransient(typeof(IResourceProxy), typeof(UwpResourceClient));
services.AddTransient(typeof(ISettingsProxy), typeof(UwpSettingsClient));
- services.AddTransient(typeof(IRecentProxy), typeof(UwpRecentFilesClient));
- services.AddTransient(typeof(IFileProxy), typeof(StorageFileClient));
+ services.AddTransient(typeof(IRecentProxy), typeof(UwpRecentFilesClient));*/
+ services.AddScoped(typeof(IFileProxy), typeof(StorageFileClient));
+ services.AddTransient(typeof(IDateTime), typeof(MachineDateTime));
return services;
}
}
diff --git a/ModernKeePass.Infrastructure/KeePass/KeePassDatabaseClient.cs b/ModernKeePass.Infrastructure/KeePass/KeePassDatabaseClient.cs
index 17a5f33..6f73ada 100644
--- a/ModernKeePass.Infrastructure/KeePass/KeePassDatabaseClient.cs
+++ b/ModernKeePass.Infrastructure/KeePass/KeePassDatabaseClient.cs
@@ -7,6 +7,7 @@ using ModernKeePass.Domain.Dtos;
using ModernKeePass.Domain.Entities;
using ModernKeePass.Domain.Enums;
using ModernKeePass.Domain.Exceptions;
+using ModernKeePass.Domain.Interfaces;
using ModernKeePassLib;
using ModernKeePassLib.Cryptography.KeyDerivation;
using ModernKeePassLib.Interfaces;
@@ -22,6 +23,7 @@ namespace ModernKeePass.Infrastructure.KeePass
private readonly ISettingsProxy _settings;
private readonly IFileProxy _fileService;
private readonly IMapper _mapper;
+ private readonly IDateTime _dateTime;
private readonly PwDatabase _pwDatabase = new PwDatabase();
private string _fileAccessToken;
private Credentials _credentials;
@@ -38,19 +40,19 @@ namespace ModernKeePass.Infrastructure.KeePass
set { _pwDatabase.RecycleBinEnabled = value; }
}
- public string RecycleBinId
+ public GroupEntity RecycleBin
{
get
{
if (_pwDatabase.RecycleBinEnabled)
{
var pwGroup = _pwDatabase.RootGroup.FindGroup(_pwDatabase.RecycleBinUuid, true);
- return pwGroup.Uuid.ToHexString();
+ return _mapper.Map(pwGroup);
}
return null;
}
- set { _pwDatabase.RecycleBinUuid = BuildIdFromString(value); }
+ set { _pwDatabase.RecycleBinUuid = BuildIdFromString(value.Id); }
}
public string CipherId
@@ -74,12 +76,13 @@ namespace ModernKeePass.Infrastructure.KeePass
get { return _pwDatabase.Compression.ToString("G"); }
set { _pwDatabase.Compression = (PwCompressionAlgorithm) Enum.Parse(typeof(PwCompressionAlgorithm), value); }
}
-
- public KeePassDatabaseClient(ISettingsProxy settings, IFileProxy fileService, IMapper mapper)
+
+ public KeePassDatabaseClient(ISettingsProxy settings, IFileProxy fileService, IMapper mapper, IDateTime dateTime)
{
_settings = settings;
_fileService = fileService;
_mapper = mapper;
+ _dateTime = dateTime;
}
public async Task Open(FileInfo fileInfo, Credentials credentials)
@@ -94,7 +97,8 @@ namespace ModernKeePass.Infrastructure.KeePass
_credentials = credentials;
_fileAccessToken = fileInfo.Path;
- return _mapper.Map(_pwDatabase.RootGroup);
+ RootGroup = _mapper.Map(_pwDatabase.RootGroup);
+ return RootGroup;
}
catch (InvalidCompositeKeyException ex)
{
@@ -124,7 +128,8 @@ namespace ModernKeePass.Infrastructure.KeePass
_fileAccessToken = fileInfo.Path;
- return _mapper.Map(_pwDatabase.RootGroup);
+ RootGroup = _mapper.Map(_pwDatabase.RootGroup);
+ return RootGroup;
}
public async Task SaveDatabase()
@@ -157,7 +162,13 @@ namespace ModernKeePass.Infrastructure.KeePass
throw new SaveException(e);
}
}
-
+
+ public void SetRecycleBin(string id)
+ {
+ _pwDatabase.RecycleBinUuid = BuildIdFromString(id);
+ _pwDatabase.RecycleBinChanged = _dateTime.Now;
+ }
+
public void CloseDatabase()
{
_pwDatabase?.Close();
diff --git a/ModernKeePass/Actions/DeleteEntityAction.cs b/ModernKeePass/Actions/DeleteEntityAction.cs
index ba23276..27432fc 100644
--- a/ModernKeePass/Actions/DeleteEntityAction.cs
+++ b/ModernKeePass/Actions/DeleteEntityAction.cs
@@ -1,9 +1,9 @@
using System.Windows.Input;
using Windows.UI.Xaml;
using Microsoft.Xaml.Interactivity;
-using ModernKeePass.Application.Resources.Queries;
using ModernKeePass.Common;
using ModernKeePass.Interfaces;
+using ModernKeePass.Services;
using ModernKeePass.ViewModels;
namespace ModernKeePass.Actions
@@ -32,23 +32,19 @@ namespace ModernKeePass.Actions
public object Execute(object sender, object parameter)
{
- var mediator = App.Mediator;
+ var resource = new ResourcesService();
var type = Entity is GroupVm ? "Group" : "Entry";
-
+
var message = Entity.IsRecycleOnDelete
- ? mediator.Send(new GetResourceQuery { Key = $"{type}RecyclingConfirmation" })
- : mediator.Send(new GetResourceQuery { Key = $"{type}DeletingConfirmation" });
- var text = Entity.IsRecycleOnDelete ?
- mediator.Send(new GetResourceQuery { Key = $"{type}Recycled" }) :
- mediator.Send(new GetResourceQuery { Key = $"{type}Deleted" });
- MessageDialogHelper.ShowActionDialog(
- mediator.Send(new GetResourceQuery { Key = "EntityDeleteTitle" }).GetAwaiter().GetResult(),
- message.GetAwaiter().GetResult(),
- mediator.Send(new GetResourceQuery { Key = "EntityDeleteActionButton" }).GetAwaiter().GetResult(),
- mediator.Send(new GetResourceQuery { Key = "EntityDeleteCancelButton" }).GetAwaiter().GetResult(), async a =>
+ ? resource.GetResourceValue($"{type}RecyclingConfirmation")
+ : resource.GetResourceValue($"{type}DeletingConfirmation");
+ var text = Entity.IsRecycleOnDelete ? resource.GetResourceValue($"{type}Recycled") : resource.GetResourceValue($"{type}Deleted");
+ MessageDialogHelper.ShowActionDialog(resource.GetResourceValue("EntityDeleteTitle"), message,
+ resource.GetResourceValue("EntityDeleteActionButton"),
+ resource.GetResourceValue("EntityDeleteCancelButton"), a =>
{
- ToastNotificationHelper.ShowMovedToast(Entity, await mediator.Send(new GetResourceQuery { Key = "EntityDeleting" }), await text);
- await Entity.MarkForDelete(await mediator.Send(new GetResourceQuery { Key = "RecycleBinTitle"}));
+ ToastNotificationHelper.ShowMovedToast(Entity, resource.GetResourceValue("EntityDeleting"), text);
+ Entity.MarkForDelete(resource.GetResourceValue("RecycleBinTitle"));
Command.Execute(null);
}, null).GetAwaiter();
diff --git a/ModernKeePass/Interfaces/IDatabaseService.cs b/ModernKeePass/Interfaces/IDatabaseService.cs
deleted file mode 100644
index 5b4c37d..0000000
--- a/ModernKeePass/Interfaces/IDatabaseService.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using System.Threading.Tasks;
-using Windows.Storage;
-using ModernKeePass.ViewModels;
-using ModernKeePassLib;
-using ModernKeePassLib.Cryptography.KeyDerivation;
-using ModernKeePassLib.Keys;
-
-namespace ModernKeePass.Interfaces
-{
- public interface IDatabaseService
- {
- string Name { get; }
- bool RecycleBinEnabled { get; set; }
- GroupVm RootGroup { get; set; }
- GroupVm RecycleBin { get; set; }
- PwUuid DataCipher { get; set; }
- PwCompressionAlgorithm CompressionAlgorithm { get; set; }
- KdfParameters KeyDerivation { get; set; }
- bool IsOpen { get; }
- bool HasChanged { get; set; }
-
- Task Open(StorageFile databaseFile, CompositeKey key, bool createNew = false);
- Task ReOpen();
- void Save();
- Task Save(StorageFile file);
- void CreateRecycleBin(string title);
- void AddDeletedItem(PwUuid id);
- void Close(bool releaseFile = true);
- void UpdateCompositeKey(CompositeKey newCompositeKey);
- }
-}
\ No newline at end of file
diff --git a/ModernKeePass/ViewModels/EntryVm.cs b/ModernKeePass/ViewModels/EntryVm.cs
index c144088..90cfc12 100644
--- a/ModernKeePass/ViewModels/EntryVm.cs
+++ b/ModernKeePass/ViewModels/EntryVm.cs
@@ -10,18 +10,17 @@ using ModernKeePass.Application.Database.Queries.GetDatabase;
using ModernKeePass.Application.Entry.Commands.SetFieldValue;
using ModernKeePass.Application.Group.Commands.CreateGroup;
using ModernKeePass.Application.Group.Commands.DeleteEntry;
-using ModernKeePass.Application.Resources.Queries;
using ModernKeePass.Application.Security.Commands.GeneratePassword;
using ModernKeePass.Application.Security.Queries.EstimatePasswordComplexity;
using ModernKeePass.Common;
+using ModernKeePass.Domain.Interfaces;
using ModernKeePass.Interfaces;
+using ModernKeePass.Services;
namespace ModernKeePass.ViewModels
{
public class EntryVm : NotifyPropertyChangedBase, IVmEntity, ISelectableModel
{
- public GroupVm ParentGroup { get; private set; }
- public GroupVm PreviousGroup { get; private set; }
public bool IsRevealPasswordEnabled => !string.IsNullOrEmpty(Password);
public bool HasExpired => HasExpirationDate && ExpiryDate < DateTime.Now;
public double PasswordComplexityIndicator => _mediator.Send(new EstimatePasswordComplexityQuery {Password = Password}).GetAwaiter().GetResult();
@@ -35,7 +34,7 @@ namespace ModernKeePass.ViewModels
public bool BracketsPatternSelected { get; set; }
public string CustomChars { get; set; } = string.Empty;
public string Id => _entry.Id;
- public bool IsRecycleOnDelete => GetDatabase().IsRecycleBinEnabled && !ParentGroup.IsSelected;
+ public bool IsRecycleOnDelete => _database.IsRecycleBinEnabled && !ParentGroup.IsSelected;
public IEnumerable BreadCrumb => new List(ParentGroup.BreadCrumb) {ParentGroup};
///
/// Determines if the Entry is current or from history
@@ -197,20 +196,23 @@ namespace ModernKeePass.ViewModels
private readonly Application.Entry.Models.EntryVm _entry;
private readonly IMediator _mediator;
+ private readonly IResourceService _resource;
+ private DatabaseVm _database;
private bool _isEditMode;
private bool _isRevealPassword;
private double _passwordLength = 25;
private bool _isVisible = true;
-
+
public EntryVm() { }
- internal EntryVm(Application.Entry.Models.EntryVm entry, GroupVm parent) : this(entry, parent, App.Mediator) { }
+ internal EntryVm(Application.Entry.Models.EntryVm entry, Application.Group.Models.GroupVm parent) : this(entry, parent, App.Mediator, new ResourcesService()) { }
- public EntryVm(Application.Entry.Models.EntryVm entry, GroupVm parent, IMediator mediator)
+ public EntryVm(Application.Entry.Models.EntryVm entry, Application.Group.Models.GroupVm parent, IMediator mediator, IResourceService resource)
{
_entry = entry;
_mediator = mediator;
- ParentGroup = parent;
+ _resource = resource;
+ _database = _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
SaveCommand = new RelayCommand(() => _mediator.Send(new SaveDatabaseCommand()));
GeneratePasswordCommand = new RelayCommand(async () => await GeneratePassword());
@@ -238,13 +240,12 @@ namespace ModernKeePass.ViewModels
public async Task MarkForDelete(string recycleBinTitle)
{
- var database = GetDatabase();
- if (database.IsRecycleBinEnabled && database.RecycleBinId == null)
- await _mediator.Send(new CreateGroupCommand { ParentGroup = database.RootGroup, IsRecycleBin = true, Name = recycleBinTitle});
- await Move(database.IsRecycleBinEnabled && !ParentGroup.IsSelected ? _database.RecycleBin : null);
+ if (_database.IsRecycleBinEnabled && _database.RecycleBin == null)
+ await _mediator.Send(new CreateGroupCommand { ParentGroup = _database.RootGroup, IsRecycleBin = true, Name = recycleBinTitle});
+ await Move(_database.IsRecycleBinEnabled && !ParentGroup.IsSelected ? _database.RecycleBin : null);
}
- public async Task Move(GroupVm destination)
+ public async Task Move(Application.Group.Models.GroupVm destination)
{
PreviousGroup = ParentGroup;
PreviousGroup.Entries.Remove(this);
@@ -270,13 +271,8 @@ namespace ModernKeePass.ViewModels
public override string ToString()
{
return IsSelected ?
- _mediator.Send(new GetResourceQuery{Key = "EntryCurrent"}).GetAwaiter().GetResult() :
+ _resource.GetResourceValue("EntryCurrent") :
_entry.ModificationDate.ToString("g");
}
-
- private DatabaseVm GetDatabase()
- {
- return _mediator.Send(new GetDatabaseQuery()).GetAwaiter().GetResult();
- }
}
}
diff --git a/ModernKeePass/ViewModels/GroupVm.cs b/ModernKeePass/ViewModels/GroupVm.cs
index 73e7b6c..d594a6f 100644
--- a/ModernKeePass/ViewModels/GroupVm.cs
+++ b/ModernKeePass/ViewModels/GroupVm.cs
@@ -20,6 +20,7 @@ using ModernKeePass.Application.Group.Commands.SortEntries;
using ModernKeePass.Application.Group.Commands.SortGroups;
using ModernKeePass.Common;
using ModernKeePass.Domain.Enums;
+using ModernKeePass.Domain.Interfaces;
using ModernKeePass.Interfaces;
namespace ModernKeePass.ViewModels
diff --git a/ModernKeePass/Win81App.csproj b/ModernKeePass/Win81App.csproj
index 40d3fae..b776bc3 100644
--- a/ModernKeePass/Win81App.csproj
+++ b/ModernKeePass/Win81App.csproj
@@ -149,9 +149,6 @@
-
-
-
ImportExportPage.xaml
@@ -191,7 +188,6 @@
-
MainPage.xaml