2020-03-26 12:25:22 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Drawing;
|
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;
|
2020-03-30 19:43:04 +02:00
|
|
|
|
using ModernKeePass.Application.Group.Models;
|
2020-03-24 13:01:14 +01:00
|
|
|
|
using ModernKeePass.Domain.Entities;
|
|
|
|
|
using ModernKeePass.Domain.Enums;
|
|
|
|
|
|
|
|
|
|
namespace ModernKeePass.Application.Entry.Models
|
|
|
|
|
{
|
2020-03-30 19:43:04 +02:00
|
|
|
|
public class EntryVm: IEntityVm, IMapFrom<EntryEntity>
|
2020-03-24 13:01:14 +01:00
|
|
|
|
{
|
2020-03-30 19:43:04 +02:00
|
|
|
|
public GroupVm ParentGroup { get; set; }
|
2020-03-31 19:19:02 +02:00
|
|
|
|
public List<GroupVm> Breadcrumb { get; } = new List<GroupVm>();
|
2020-03-24 13:01:14 +01:00
|
|
|
|
public string Id { get; set; }
|
|
|
|
|
public string Title { get; set; }
|
2020-03-26 12:25:22 +01:00
|
|
|
|
public string Username { get; set; }
|
|
|
|
|
public string Password { get; set; }
|
|
|
|
|
public string Notes { get; set; }
|
|
|
|
|
public Uri Url { get; set; }
|
|
|
|
|
public Dictionary<string, string> AdditionalFields { get; set; }
|
2020-03-27 13:27:29 +01:00
|
|
|
|
public IEnumerable<EntryVm> History { get; set; }
|
2020-03-24 13:01:14 +01:00
|
|
|
|
public Icon Icon { get; set; }
|
|
|
|
|
public Color ForegroundColor { get; set; }
|
|
|
|
|
public Color BackgroundColor { get; set; }
|
2020-03-31 19:19:02 +02:00
|
|
|
|
public bool HasExpirationDate { get; set; }
|
|
|
|
|
public DateTimeOffset ExpirationDate { get; set; }
|
|
|
|
|
public DateTimeOffset ModificationDate { get; set; }
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return ModificationDate.ToString("g");
|
|
|
|
|
}
|
2020-03-24 13:01:14 +01:00
|
|
|
|
|
|
|
|
|
public void Mapping(Profile profile)
|
|
|
|
|
{
|
|
|
|
|
profile.CreateMap<EntryEntity, EntryVm>()
|
2020-04-01 12:48:36 +02:00
|
|
|
|
.ForMember(d => d.ParentGroup, opts => opts.Ignore())
|
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-03-26 12:25:22 +01:00
|
|
|
|
.ForMember(d => d.Username, opts => opts.MapFrom(s => s.UserName))
|
|
|
|
|
.ForMember(d => d.Password, opts => opts.MapFrom(s => s.Password))
|
|
|
|
|
.ForMember(d => d.Url, opts => opts.MapFrom(s => s.Url))
|
|
|
|
|
.ForMember(d => d.Notes, opts => opts.MapFrom(s => s.Notes))
|
|
|
|
|
.ForMember(d => d.AdditionalFields, opts => opts.MapFrom(s => s.AdditionalFields))
|
|
|
|
|
.ForMember(d => d.History, opts => opts.MapFrom(s => s.History))
|
|
|
|
|
.ForMember(d => d.HasExpirationDate, opts => opts.MapFrom(s => s.HasExpirationDate))
|
|
|
|
|
.ForMember(d => d.ExpirationDate, opts => opts.MapFrom(s => s.ExpirationDate))
|
|
|
|
|
.ForMember(d => d.ModificationDate, opts => opts.MapFrom(s => s.LastModificationDate))
|
2020-03-24 13:01:14 +01:00
|
|
|
|
.ForMember(d => d.Icon, opts => opts.MapFrom(s => s.Icon))
|
|
|
|
|
.ForMember(d => d.ForegroundColor, opts => opts.MapFrom(s => s.ForegroundColor))
|
|
|
|
|
.ForMember(d => d.BackgroundColor, opts => opts.MapFrom(s => s.BackgroundColor));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|