MapTo/test/TestConsoleApp/ViewModels/UserViewModel.cs

24 lines
654 B
C#
Raw Normal View History

2021-02-07 13:51:49 +03:00
using System;
using MapTo;
using TestConsoleApp.Data.Models;
namespace TestConsoleApp.ViewModels
{
2021-02-07 13:51:49 +03:00
[MapFrom(typeof(User))]
public partial class UserViewModel
{
2021-02-07 13:51:49 +03:00
[MapProperty(SourcePropertyName = nameof(User.Id))]
[MapTypeConverter(typeof(IdConverter))]
public string Key { get; }
2021-02-07 13:51:49 +03:00
public DateTimeOffset RegisteredAt { get; set; }
2021-01-07 11:17:36 +03:00
2021-02-07 13:51:49 +03:00
// [IgnoreProperty]
public ProfileViewModel Profile { get; set; }
2021-01-07 11:17:36 +03:00
2021-02-07 13:51:49 +03:00
private class IdConverter : ITypeConverter<int, string>
2021-01-07 11:17:36 +03:00
{
2021-02-07 13:51:49 +03:00
public string Convert(int source, object[] converterParameters) => $"{source:X}";
2021-01-07 11:17:36 +03:00
}
}
}