2020-04-01 19:37:30 +02:00
|
|
|
|
using System.Collections.Generic;
|
2020-03-24 13:01:14 +01:00
|
|
|
|
using AutoMapper;
|
2020-03-30 19:43:04 +02:00
|
|
|
|
using ModernKeePass.Application.Common.Interfaces;
|
2020-03-24 13:01:14 +01:00
|
|
|
|
using ModernKeePass.Application.Common.Mappings;
|
|
|
|
|
using ModernKeePass.Application.Entry.Models;
|
|
|
|
|
using ModernKeePass.Domain.Entities;
|
|
|
|
|
using ModernKeePass.Domain.Enums;
|
2020-03-30 19:43:04 +02:00
|
|
|
|
using ModernKeePass.Domain.Interfaces;
|
2020-03-24 13:01:14 +01:00
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Application.Group.Models
|
|
|
|
|
{
|
2020-03-30 19:43:04 +02:00
|
|
|
|
public class GroupVm: IEntityVm, ISelectableModel, IMapFrom<GroupEntity>
|
2020-03-24 13:01:14 +01:00
|
|
|
|
{
|
2020-04-01 19:37:30 +02:00
|
|
|
|
public string ParentGroupId { get; set; }
|
2020-04-02 19:12:16 +02:00
|
|
|
|
public string ParentGroupName { get; set; }
|
2020-03-24 13:01:14 +01:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
public Icon Icon { get; set; }
|
2020-03-30 19:43:04 +02:00
|
|
|
|
public List<GroupVm> SubGroups { get; set; }
|
|
|
|
|
public List<EntryVm> Entries { get; set; }
|
|
|
|
|
public bool IsSelected { get; set; }
|
2020-03-31 19:19:02 +02:00
|
|
|
|
|
2020-03-30 19:43:04 +02:00
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return Title;
|
|
|
|
|
}
|
2020-03-24 13:01:14 +01:00
|
|
|
|
|
|
|
|
|
public void Mapping(Profile profile)
|
|
|
|
|
{
|
|
|
|
|
profile.CreateMap<GroupEntity, GroupVm>()
|
2020-04-01 19:37:30 +02:00
|
|
|
|
.ForMember(d => d.ParentGroupId, opts => opts.MapFrom(s => s.ParentId))
|
2020-04-02 19:12:16 +02:00
|
|
|
|
.ForMember(d => d.ParentGroupName, opts => opts.MapFrom(s => s.ParentName))
|
2020-03-24 13:01:14 +01:00
|
|
|
|
.ForMember(d => d.Id, opts => opts.MapFrom(s => s.Id))
|
|
|
|
|
.ForMember(d => d.Title, opts => opts.MapFrom(s => s.Name))
|
2020-04-01 12:48:36 +02:00
|
|
|
|
.ForMember(d => d.Icon, opts => opts.MapFrom(s => s.Icon))
|
2020-04-01 19:37:30 +02:00
|
|
|
|
.ForMember(d => d.Entries, opts => opts.MapFrom(s => s.Entries))
|
|
|
|
|
.ForMember(d => d.SubGroups, opts => opts.MapFrom(s => s.SubGroups))
|
2020-04-02 19:12:16 +02:00
|
|
|
|
.MaxDepth(2);
|
2020-04-01 12:48:36 +02:00
|
|
|
|
}
|
2020-03-24 13:01:14 +01:00
|
|
|
|
}
|
|
|
|
|
}
|