-
Notifications
You must be signed in to change notification settings - Fork 26
/
AutoMapperProfile.cs
67 lines (55 loc) · 2.4 KB
/
AutoMapperProfile.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using AutoMapper;
using NextGenSoftware.OASIS.API.Core.Interfaces;
using NextGenSoftware.OASIS.API.ONode.WebAPI.Models.Security;
namespace NextGenSoftware.OASIS.API.ONode.WebAPI.Helpers
{
public class AutoMapperProfile : Profile
{
// mappings between model and entity objects
public AutoMapperProfile()
{
//CreateMap<Core.Avatar, AccountResponse>();
//CreateMap<Core.Avatar, AuthenticateResponse>();
//CreateMap<IAvatar, AccountResponse>();
//CreateMap<IAvatar, AuthenticateResponse>();
//CreateMap<RegisterRequest, Core.Avatar>();
//CreateMap<CreateRequest, Core.Avatar>();
//CreateMap<RegisterRequest, IAvatar>();
CreateMap<CreateRequest, IAvatar>();
CreateMap<API.Core.Holons.Avatar, IAvatar>();
CreateMap<UpdateRequest, IAvatar>()
.ForAllMembers(x => x.Condition(
(src, dest, prop) =>
{
// ignore null & empty string properties
if (prop == null)
return false;
if (prop.GetType() == typeof(string) && string.IsNullOrEmpty((string)prop))
return false;
// ignore null AvatarType
if (x.DestinationMember.Name == "AvatarType" && src.AvatarType == null)
return false;
return true;
}
));
CreateMap<RegisterRequest, IAvatar>()
.ForAllMembers(x => x.Condition(
(src, dest, prop) =>
{
// ignore null & empty string properties
if (prop == null)
return false;
if (prop.GetType() == typeof(string) && string.IsNullOrEmpty((string)prop))
return false;
// ignore null AvatarType
if (x.DestinationMember.Name == "AvatarType" && src.AvatarType == null)
return false;
//x.Ignore()
if (x.DestinationMember.Name == "KarmaEarnt")
return false;
return true;
}
));
}
}
}