mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Build hierarchy instead of using Automapper
Add entities before removing them
This commit is contained in:
@@ -19,6 +19,7 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
{
|
||||
Uri url;
|
||||
CreateMap<PwEntry, EntryEntity>()
|
||||
.ForMember(dest => dest.ParentGroup, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ParentId, opt => opt.MapFrom(src => src.ParentGroup.Uuid.ToHexString()))
|
||||
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Uuid.ToHexString()))
|
||||
.ForMember(dest => dest.Name, opt => opt.MapFrom(src => GetEntryValue(src, PwDefs.TitleField)))
|
||||
|
@@ -15,13 +15,14 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
private void FromDtoToModel()
|
||||
{
|
||||
CreateMap<PwGroup, GroupEntity>()
|
||||
.ForMember(dest => dest.ParentGroup, opt => opt.Ignore())
|
||||
.ForMember(d => d.ParentId, opts => opts.MapFrom(s => s.ParentGroup.Uuid.ToHexString()))
|
||||
.ForMember(d => d.Id, opts => opts.MapFrom(s => s.Uuid.ToHexString()))
|
||||
.ForMember(d => d.Name, opts => opts.MapFrom(s => s.Name))
|
||||
.ForMember(d => d.Icon, opts => opts.MapFrom(s => IconMapper.MapPwIconToIcon(s.IconId)))
|
||||
.ForMember(d => d.LastModificationDate, opts => opts.MapFrom(s => s.LastModificationTime));
|
||||
//.ForMember(d => d.Entries, opts => opts.MapFrom(s => s.Entries))
|
||||
//.ForMember(d => d.SubGroups, opts => opts.MapFrom(s => s.Groups));
|
||||
.ForMember(d => d.LastModificationDate, opts => opts.MapFrom(s => s.LastModificationTime))
|
||||
.ForMember(d => d.Entries, opts => opts.Ignore())
|
||||
.ForMember(d => d.SubGroups, opts => opts.Ignore());
|
||||
}
|
||||
|
||||
private void FromModelToDto()
|
||||
|
@@ -340,11 +340,11 @@ namespace ModernKeePass.Infrastructure.KeePass
|
||||
private GroupEntity BuildHierarchy(GroupEntity parentGroup, PwGroup pwGroup)
|
||||
{
|
||||
var group = _mapper.Map<GroupEntity>(pwGroup);
|
||||
group.Parent = parentGroup;
|
||||
group.ParentGroup = parentGroup;
|
||||
group.Entries = pwGroup.Entries.Select(e =>
|
||||
{
|
||||
var entry = _mapper.Map<EntryEntity>(e);
|
||||
entry.Parent = group;
|
||||
entry.ParentGroup = group;
|
||||
return entry;
|
||||
}).ToList();
|
||||
group.SubGroups = pwGroup.Groups.Select(g => BuildHierarchy(group, g)).ToList();
|
||||
|
Reference in New Issue
Block a user