aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Services/Configurations/Mapping/UserMappings.cs
blob: 096af38475cd4ae794e68a86b7b785e98d37c528 (plain) (blame)
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
using DevHive.Data.Models;
using AutoMapper;
using DevHive.Services.Models.Identity.User;
using DevHive.Common.Models.Misc;

namespace DevHive.Services.Configurations.Mapping
{
	public class UserMappings : Profile
	{
		public UserMappings()
		{
			CreateMap<UserServiceModel, User>();
			CreateMap<RegisterServiceModel, User>();
			CreateMap<FriendServiceModel, User>();
			CreateMap<UpdateUserServiceModel, User>()
				.AfterMap((src, dest) => dest.PasswordHash = PasswordModifications.GeneratePasswordHash(src.Password));
			CreateMap<UpdateFriendServiceModel, User>();

			CreateMap<User, UserServiceModel>();
			CreateMap<User, UpdateUserServiceModel>()
				.ForMember(x => x.Password, opt => opt.Ignore());
			CreateMap<User, FriendServiceModel>();
		}
	}
}