mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Lots of bug corrections
WIP - still lots left
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using MediatR;
|
||||
using ModernKeePass.Application.Common.Interfaces;
|
||||
using ModernKeePass.Application.Entry.Models;
|
||||
using ModernKeePass.Application.Group.Models;
|
||||
using ModernKeePass.Domain.Dtos;
|
||||
using ModernKeePass.Domain.Entities;
|
||||
using ModernKeePass.Domain.Exceptions;
|
||||
|
||||
namespace ModernKeePass.Application.Database.Queries.OpenDatabase
|
||||
@@ -39,7 +42,29 @@ namespace ModernKeePass.Application.Database.Queries.OpenDatabase
|
||||
KeyFilePath = request.KeyFilePath,
|
||||
Password = request.Password
|
||||
});
|
||||
return _mapper.Map<GroupVm>(rootGroup);
|
||||
return BuildHierarchy(null, rootGroup);
|
||||
}
|
||||
|
||||
private GroupVm BuildHierarchy(GroupVm parentGroup, GroupEntity groupEntity)
|
||||
{
|
||||
var groupVm = _mapper.Map<GroupVm>(groupEntity);
|
||||
groupVm.ParentGroup = parentGroup;
|
||||
if (parentGroup != null)
|
||||
{
|
||||
groupVm.Breadcrumb.AddRange(parentGroup.Breadcrumb);
|
||||
groupVm.Breadcrumb.Add(parentGroup);
|
||||
}
|
||||
groupVm.Entries = groupEntity.Entries.Select(e =>
|
||||
{
|
||||
var entry = _mapper.Map<EntryVm>(e);
|
||||
entry.ParentGroup = groupVm;
|
||||
entry.Breadcrumb.AddRange(groupVm.Breadcrumb);
|
||||
entry.Breadcrumb.Add(groupVm);
|
||||
return entry;
|
||||
}).OrderBy(e => e.Title).ToList();
|
||||
groupVm.SubGroups = groupEntity.SubGroups.Select(g => BuildHierarchy(groupVm, g)).ToList();
|
||||
|
||||
return groupVm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user