2020-03-26 12:25:22 +01:00
|
|
|
|
using AutoMapper;
|
|
|
|
|
using MediatR;
|
2020-03-24 17:31:34 +01:00
|
|
|
|
using ModernKeePass.Application.Common.Interfaces;
|
|
|
|
|
using ModernKeePass.Application.Database.Models;
|
2020-03-26 12:25:22 +01:00
|
|
|
|
using ModernKeePass.Application.Group.Models;
|
2020-03-24 17:31:34 +01:00
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Application.Database.Queries.GetDatabase
|
|
|
|
|
{
|
|
|
|
|
public class GetDatabaseQuery: IRequest<DatabaseVm>
|
|
|
|
|
{
|
|
|
|
|
public class GetDatabaseQueryHandler : IRequestHandler<GetDatabaseQuery, DatabaseVm>
|
|
|
|
|
{
|
|
|
|
|
private readonly IDatabaseProxy _databaseProxy;
|
2020-03-26 12:25:22 +01:00
|
|
|
|
private readonly IMapper _mapper;
|
2020-03-24 17:31:34 +01:00
|
|
|
|
|
2020-03-26 12:25:22 +01:00
|
|
|
|
public GetDatabaseQueryHandler(IDatabaseProxy databaseProxy, IMapper mapper)
|
2020-03-24 17:31:34 +01:00
|
|
|
|
{
|
|
|
|
|
_databaseProxy = databaseProxy;
|
2020-03-26 12:25:22 +01:00
|
|
|
|
_mapper = mapper;
|
2020-03-24 17:31:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public DatabaseVm Handle(GetDatabaseQuery request)
|
|
|
|
|
{
|
|
|
|
|
var database = new DatabaseVm
|
|
|
|
|
{
|
|
|
|
|
IsOpen = _databaseProxy.IsOpen,
|
2020-03-26 12:25:22 +01:00
|
|
|
|
Name = _databaseProxy.Name,
|
|
|
|
|
RootGroup = _mapper.Map<GroupVm>(_databaseProxy.RootGroup),
|
|
|
|
|
IsRecycleBinEnabled = _databaseProxy.IsRecycleBinEnabled,
|
|
|
|
|
RecycleBinId = _databaseProxy.RecycleBinId,
|
|
|
|
|
Compression = _databaseProxy.Compression,
|
|
|
|
|
CipherId = _databaseProxy.CipherId,
|
|
|
|
|
KeyDerivationId = _databaseProxy.CipherId
|
2020-03-24 17:31:34 +01:00
|
|
|
|
};
|
|
|
|
|
return database;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|