2020-03-24 13:01:14 +01:00
|
|
|
|
using System.Collections.Generic;
|
2020-03-26 12:25:22 +01:00
|
|
|
|
using System.Linq;
|
2020-03-24 13:01:14 +01:00
|
|
|
|
using AutoMapper;
|
|
|
|
|
using ModernKeePass.Application.Common.Mappings;
|
|
|
|
|
using ModernKeePass.Application.Entry.Models;
|
|
|
|
|
using ModernKeePass.Domain.Entities;
|
|
|
|
|
using ModernKeePass.Domain.Enums;
|
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Application.Group.Models
|
|
|
|
|
{
|
|
|
|
|
public class GroupVm: IMapFrom<GroupEntity>
|
|
|
|
|
{
|
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
public Icon Icon { get; set; }
|
2020-03-28 16:13:17 +01:00
|
|
|
|
public GroupVm ParentGroup { get; set; }
|
2020-03-24 13:01:14 +01:00
|
|
|
|
public List<GroupVm> SubGroups { get; set; } = new List<GroupVm>();
|
|
|
|
|
public List<EntryVm> Entries { get; set; } = new List<EntryVm>();
|
|
|
|
|
|
|
|
|
|
public void Mapping(Profile profile)
|
|
|
|
|
{
|
|
|
|
|
profile.CreateMap<GroupEntity, GroupVm>()
|
|
|
|
|
.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))
|
2020-03-28 16:13:17 +01:00
|
|
|
|
.ForMember(d => d.ParentGroup, opts => opts.MapFrom(s => s.Parent))
|
2020-03-26 12:25:22 +01:00
|
|
|
|
.ForMember(d => d.Entries, opts => opts.MapFrom(s => s.Entries.OrderBy(e => e.Name)))
|
2020-03-24 13:01:14 +01:00
|
|
|
|
.ForMember(d => d.SubGroups, opts => opts.MapFrom(s => s.SubGroups));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|