예제 #1
0
        public PermissionContractProfile(IRoleSorter roleSorter)
        {
            CreateMap <PermissionInfoModel, PermissionContractBase>()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name))
            .ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.Description));

            CreateMap <PermissionInfoModel, PermissionContract>()
            .IncludeBase <PermissionInfoModel, PermissionContractBase>()
            .ForMember(dest => dest.Roles, opt => opt.Ignore());

            CreateMap <PermissionModel, PermissionContract>()
            .IncludeBase <PermissionInfoModel, PermissionContract>()
            .ForMember(dest => dest.Roles, opt => opt.MapFrom(src => src.Roles))
            .AfterMap((src, dest) => { dest.Roles = roleSorter.SortRoles(dest.Roles); });

            CreateMap <PermissionContractBase, PermissionInfoModel>()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name))
            .ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.Description));

            CreateMap <PermissionContractBase, PermissionModel>()
            .IncludeBase <PermissionContractBase, PermissionInfoModel>();

            CreateMap <PermissionContract, PermissionModel>()
            .IncludeBase <PermissionContractBase, PermissionModel>()
            .ForMember(dest => dest.Roles, opt => opt.MapFrom(src => src.Roles))
            .AfterMap((src, dest) => { dest.Roles = roleSorter.SortRoles(dest.Roles); });
        }
        public ResourcePermissionTypeActionProfile(IRoleSorter roleSorter, IUserInfoSorter userInfoSorter, IUserSorter userSorter)
        {
            CreateMap <ResourcePermissionTypeActionInfoModel, ResourcePermissionTypeActionViewModel>()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name))
            .ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.Description))
            .ForMember(dest => dest.ResourcePermissionType, opt => opt.MapFrom(src => src.ResourcePermissionType));

            CreateMap <ResourcePermissionTypeActionViewModel, ResourcePermissionTypeActionInfoModel>()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name))
            .ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.Description))
            .ForMember(dest => dest.ResourcePermissionType, opt => opt.MapFrom(src => src.ResourcePermissionType));

            CreateMap <ResourcePermissionTypeActionModel, ResourcePermissionTypeActionViewModel>()
            .IncludeBase <ResourcePermissionTypeActionInfoModel, ResourcePermissionTypeActionViewModel>()
            .ForMember(dest => dest.Users, opt => opt.MapFrom(src => src.Users))
            .ForMember(dest => dest.Roles, opt => opt.MapFrom(src => src.Roles))
            .AfterMap((src, dest) =>
            {
                dest.Roles = roleSorter.SortRoles(dest.Roles);
                dest.Users = userSorter.SortUsers(dest.Users);
            });

            CreateMap <ResourcePermissionTypeActionViewModel, ResourcePermissionTypeActionModel>()
            .IncludeBase <ResourcePermissionTypeActionViewModel, ResourcePermissionTypeActionInfoModel>()
            .ForMember(dest => dest.Users, opt => opt.MapFrom(src => src.Users))
            .ForMember(dest => dest.Roles, opt => opt.MapFrom(src => src.Roles))
            .AfterMap((src, dest) =>
            {
                dest.Roles = roleSorter.SortRoles(dest.Roles);
                dest.Users = userInfoSorter.SortUserInfos(dest.Users);
            });

            CreateMap <ResourcePermissionTypeActionViewModel, ResourcePermissionTypeActionViewModel>()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.Name, opt => opt.MapFrom(src => src.Name))
            .ForMember(dest => dest.Description, opt => opt.MapFrom(src => src.Description))
            .ForMember(dest => dest.ResourcePermissionType, opt => opt.MapFrom(src => src.ResourcePermissionType))
            .ForMember(dest => dest.Users, opt => opt.MapFrom(src => src.Users))
            .ForMember(dest => dest.Roles, opt => opt.MapFrom(src => src.Roles))
            .AfterMap((src, dest) =>
            {
                dest.Roles = roleSorter.SortRoles(dest.Roles);
                dest.Users = userSorter.SortUsers(dest.Users);
            });

            CreateMap <ResourcePermissionTypeActionViewModel, EditResourcePermissionTypeActionViewModel>()
            .IncludeBase <ResourcePermissionTypeActionViewModel, ResourcePermissionTypeActionViewModel>()
            .ForMember(dest => dest.ResourcePermissionTypeList, opt => opt.Ignore());
        }
예제 #3
0
        public UserProfile(IRoleSorter roleSorter, IResourcePermissionSorter resourcePermissionSorter,
                           IResourcePermissionTypeActionSorter resourcePermissionTypeActionSorter, IClaimTypeSorter claimTypeSorter,
                           IUserDataSorter userDataSorter, IContactSorter contactSorter, IClaimSorter claimSorter)
        {
            CreateMap <UserInfoModel, UserViewModel>()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.Username))
            .ForMember(dest => dest.TwoFactorEnabled, opt => opt.MapFrom(src => src.TwoFactorEnabled))
            .ForMember(dest => dest.LockoutEndDateUtc, opt => opt.MapFrom(src => src.LockoutEndDateUtc))
            .ForMember(dest => dest.LockoutEnabled, opt => opt.MapFrom(src => src.LockoutEnabled))
            .ForMember(dest => dest.AccessFailedCount, opt => opt.MapFrom(src => src.AccessFailedCount))
            .ForMember(dest => dest.TwoFactorProvider, opt => opt.MapFrom(src => src.TwoFactorProvider))
            .ForMember(dest => dest.LastChange, opt => opt.MapFrom(src => src.LastChange))
            .ForMember(dest => dest.VerificationCode, opt => opt.MapFrom(src => src.VerificationCode))
            .ForMember(dest => dest.VerificationCodeCreateTime, opt => opt.MapFrom(src => src.VerificationCodeCreateTime));

            CreateMap <UserModel, UserViewModel>()
            .IncludeBase <UserInfoModel, UserViewModel>()
            .ForMember(dest => dest.FirstName, opt => opt.MapFrom(new UserDataStringValueResolver <UserViewModel>(UserDataTypes.FirstName)))
            .ForMember(dest => dest.LastName, opt => opt.MapFrom(new UserDataStringValueResolver <UserViewModel>(UserDataTypes.LastName)))
            .ForMember(dest => dest.Email,
                       opt => opt.MapFrom(new UserContactValueResolver <UserViewModel>(ContactTypeEnumModel.Email)))
            .ForMember(dest => dest.EmailLevelOfAssurance,
                       opt => opt.MapFrom(new UserContactLevelOfAssuranceResolver <UserViewModel>(ContactTypeEnumModel.Email)))
            .ForMember(dest => dest.EmailConfirmCode,
                       opt => opt.MapFrom(new UserContactConfirmCodeResolver <UserViewModel>(ContactTypeEnumModel.Email)))
            .ForMember(dest => dest.SecurityStamp, opt => opt.MapFrom(src => src.SecurityStamp))
            .ForMember(dest => dest.PhoneNumber,
                       opt => opt.MapFrom(new UserContactValueResolver <UserViewModel>(ContactTypeEnumModel.Phone)))
            .ForMember(dest => dest.PhoneLevelOfAssurance,
                       opt => opt.MapFrom(new UserContactLevelOfAssuranceResolver <UserViewModel>(ContactTypeEnumModel.Phone)))
            .ForMember(dest => dest.PhoneNumberConfirmCode,
                       opt => opt.MapFrom(new UserContactConfirmCodeResolver <UserViewModel>(ContactTypeEnumModel.Phone)))
            .ForMember(dest => dest.TwoFactorLogins, opt => opt.MapFrom(src => src.TwoFactorLogins))
            .ForMember(dest => dest.Roles, opt => opt.MapFrom(src => src.Roles))
            .ForMember(dest => dest.ResourcePermissions, opt => opt.MapFrom(src => src.ResourcePermissions))
            .ForMember(dest => dest.ResourcePermissionTypeActions, opt => opt.MapFrom(src => src.ResourcePermissionTypeActions))
            .ForMember(dest => dest.SecondName,
                       opt => opt.MapFrom(new UserDataStringValueResolver <UserViewModel>(CustomUserDataTypes.SecondName)))
            .ForMember(dest => dest.FullName,
                       opt => opt.MapFrom(new UserDataStringValueResolver <UserViewModel>(CustomUserDataTypes.FullName)))
            .ForMember(dest => dest.Title, opt => opt.MapFrom(new TitleUserDataResolver <UserViewModel>(CustomUserDataTypes.Title)))
            .ForMember(dest => dest.Prefix, opt => opt.MapFrom(new UserDataStringValueResolver <UserViewModel>(CustomUserDataTypes.Prefix)))
            .ForMember(dest => dest.Suffix, opt => opt.MapFrom(new UserDataStringValueResolver <UserViewModel>(CustomUserDataTypes.Suffix)))
            .ForMember(dest => dest.TwoFactorProviders, opt => opt.Ignore())
            .AfterMap((src, dest) =>
            {
                dest.Roles = roleSorter.SortRoles(dest.Roles);
                dest.ResourcePermissions           = resourcePermissionSorter.SortResourcePermissions(dest.ResourcePermissions);
                dest.ResourcePermissionTypeActions = resourcePermissionTypeActionSorter.SortResourcePermissionTypeActions(dest.ResourcePermissionTypeActions);
            });

            CreateMap <UserViewModel, UserInfoModel>()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.Username))
            .ForMember(dest => dest.SecurityStamp, opt => opt.MapFrom(src => src.SecurityStamp))
            .ForMember(dest => dest.TwoFactorEnabled, opt => opt.MapFrom(src => src.TwoFactorEnabled))
            .ForMember(dest => dest.LockoutEndDateUtc, opt => opt.MapFrom(src => src.LockoutEndDateUtc))
            .ForMember(dest => dest.LockoutEnabled, opt => opt.MapFrom(src => src.LockoutEnabled))
            .ForMember(dest => dest.AccessFailedCount, opt => opt.MapFrom(src => src.AccessFailedCount))
            .ForMember(dest => dest.TwoFactorProvider, opt => opt.MapFrom(src => src.TwoFactorProvider))
            .ForMember(dest => dest.VerificationCode, opt => opt.MapFrom(src => src.VerificationCode))
            .ForMember(dest => dest.VerificationCodeCreateTime, opt => opt.MapFrom(src => src.VerificationCodeCreateTime))
            .ForMember(dest => dest.LastChange, opt => opt.MapFrom(src => src.LastChange))
            .ConstructUsingServiceLocator();

            CreateMap <UserViewModel, UserModel>()
            .IncludeBase <UserViewModel, UserInfoModel>()
            .ForMember(dest => dest.TwoFactorLogins, opt => opt.MapFrom(src => src.TwoFactorLogins))
            .ForMember(dest => dest.Roles, opt => opt.MapFrom(src => src.Roles))
            .ForMember(dest => dest.ResourcePermissions, opt => opt.MapFrom(src => src.ResourcePermissions))
            .ForMember(dest => dest.ResourcePermissionTypeActions, opt => opt.MapFrom(src => src.ResourcePermissionTypeActions))
            .ForMember(dest => dest.UserClaims, opt => opt.MapFrom(src => src.UserClaims))
            .ForMember(dest => dest.UserData, opt => opt.MapFrom <UserDataToListResolver <UserViewModel> >())
            .ForMember(dest => dest.UserContacts, opt => opt.MapFrom <UserContactToListResolver <UserViewModel> >())
            .ForMember(dest => dest.ExternalIdentities, opt => opt.Ignore())
            .ForMember(dest => dest.PasswordHash, opt => opt.Ignore())
            .ForMember(dest => dest.PasswordResetToken, opt => opt.Ignore())
            .ForMember(dest => dest.PasswordResetTokenCreateTime, opt => opt.Ignore())
            .AfterMap((src, dest) =>
            {
                dest.Roles = roleSorter.SortRoles(dest.Roles);
                dest.ResourcePermissions           = resourcePermissionSorter.SortResourcePermissions(dest.ResourcePermissions);
                dest.ResourcePermissionTypeActions = resourcePermissionTypeActionSorter.SortResourcePermissionTypeActions(dest.ResourcePermissionTypeActions);
                dest.UserClaims   = claimSorter.SortClaims(dest.UserClaims);
                dest.UserData     = userDataSorter.SortUserData(dest.UserData);
                dest.UserContacts = contactSorter.SortContacts(dest.UserContacts);
            })
            .ConstructUsingServiceLocator();

            CreateMap <UserModel, ApplicationUser>()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.MasterUserId, opt => opt.MapFrom(new MasterUserIdDataResolver <ApplicationUser>(CustomUserDataTypes.MasterUserId)))
            .ForMember(dest => dest.UserName, opt => opt.MapFrom(src => src.Username))
            .ForMember(dest => dest.Email,
                       opt => opt.MapFrom(new UserContactValueResolver <ApplicationUser>(ContactTypeEnumModel.Email)))
            .ForMember(dest => dest.EmailConfirmed,
                       opt => opt.MapFrom(new UserContactConfirmResolver <ApplicationUser>(ContactTypeEnumModel.Email)))
            .ForMember(dest => dest.EmailConfirmCode,
                       opt => opt.MapFrom(new UserContactConfirmCodeResolver <ApplicationUser>(ContactTypeEnumModel.Email)))
            .ForMember(dest => dest.PasswordHash, opt => opt.MapFrom(src => src.PasswordHash))
            .ForMember(dest => dest.SecurityStamp, opt => opt.MapFrom(src => src.SecurityStamp))
            .ForMember(dest => dest.PhoneNumber,
                       opt => opt.MapFrom(new UserContactValueResolver <ApplicationUser>(ContactTypeEnumModel.Phone)))
            .ForMember(dest => dest.PhoneNumberConfirmed,
                       opt => opt.MapFrom(new UserContactConfirmResolver <ApplicationUser>(ContactTypeEnumModel.Phone)))
            .ForMember(dest => dest.PhoneNumberConfirmCode,
                       opt => opt.MapFrom(new UserContactConfirmCodeResolver <ApplicationUser>(ContactTypeEnumModel.Phone)))
            .ForMember(dest => dest.TwoFactorEnabled, opt => opt.MapFrom(src => src.TwoFactorEnabled))
            .ForMember(dest => dest.LockoutEnd, opt => opt.MapFrom(src => src.LockoutEndDateUtc))
            .ForMember(dest => dest.LockoutEnabled, opt => opt.MapFrom(src => src.LockoutEnabled))
            .ForMember(dest => dest.AccessFailedCount, opt => opt.MapFrom(src => src.AccessFailedCount))
            .ForMember(dest => dest.TwoFactorLogins, opt => opt.MapFrom(src => src.TwoFactorLogins))
            .ForMember(dest => dest.TwoFactorProvider, opt => opt.MapFrom(src => src.TwoFactorProvider))
            .ForMember(dest => dest.LastChange, opt => opt.MapFrom(src => src.LastChange))
            .ForMember(dest => dest.Roles, opt => opt.MapFrom(src => src.Roles))
            .ForMember(dest => dest.ResourcePermissions, opt => opt.MapFrom(src => src.ResourcePermissions))
            .ForMember(dest => dest.ResourcePermissionTypeActions, opt => opt.MapFrom(src => src.ResourcePermissionTypeActions))
            .ForMember(dest => dest.VerificationCode, opt => opt.MapFrom(src => src.VerificationCode))
            .ForMember(dest => dest.VerificationCodeCreateTime, opt => opt.MapFrom(src => src.VerificationCodeCreateTime))
            .ForMember(dest => dest.ExternalUserLogins, opt => opt.MapFrom(src => src.ExternalUserLogins))
            .ForMember(dest => dest.UserData, opt => opt.MapFrom(src => src.UserData))
            .ForMember(dest => dest.AuthenticatorKey, opt => opt.Ignore())
            .ForMember(dest => dest.Permissions, opt => opt.Ignore())
            .ForMember(dest => dest.NormalizedUserName, opt => opt.Ignore())
            .ForMember(dest => dest.NormalizedEmail, opt => opt.Ignore())
            .ForMember(dest => dest.ConcurrencyStamp, opt => opt.Ignore())
            .AfterMap((src, dest) =>
            {
                if (src.Roles == null)
                {
                    dest.Permissions = null;
                    return;
                }

                var permissionNames = new HashSet <string>();

                foreach (var role in src.Roles)
                {
                    foreach (var permission in role.Permissions)
                    {
                        permissionNames.Add(permission.Name);
                    }
                }

                dest.Permissions = permissionNames.OrderBy(x => x).ToList();

                dest.Roles = roleSorter.SortRoles(dest.Roles);
                dest.ResourcePermissions           = resourcePermissionSorter.SortResourcePermissions(dest.ResourcePermissions);
                dest.ResourcePermissionTypeActions = resourcePermissionTypeActionSorter.SortResourcePermissionTypeActions(dest.ResourcePermissionTypeActions);
                dest.UserData = userDataSorter.SortUserData(dest.UserData);
            });

            CreateMap <ApplicationUser, UserModel>()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.UserName))
            .ForMember(dest => dest.SecurityStamp, opt => opt.MapFrom(src => src.SecurityStamp))
            .ForMember(dest => dest.TwoFactorEnabled, opt => opt.MapFrom(src => src.TwoFactorEnabled))
            .ForMember(dest => dest.LockoutEndDateUtc, opt => opt.MapFrom(src => src.LockoutEnd))
            .ForMember(dest => dest.LockoutEnabled, opt => opt.MapFrom(src => src.LockoutEnabled))
            .ForMember(dest => dest.AccessFailedCount, opt => opt.MapFrom(src => src.AccessFailedCount))
            .ForMember(dest => dest.TwoFactorLogins, opt => opt.MapFrom(src => src.TwoFactorLogins))
            .ForMember(dest => dest.Roles, opt => opt.MapFrom(src => src.Roles))
            .ForMember(dest => dest.ResourcePermissions, opt => opt.MapFrom(src => src.ResourcePermissions))
            .ForMember(dest => dest.ResourcePermissionTypeActions, opt => opt.MapFrom(src => src.ResourcePermissionTypeActions))
            .ForMember(dest => dest.TwoFactorProvider, opt => opt.MapFrom(src => src.TwoFactorProvider))
            .ForMember(dest => dest.UserClaims, opt => opt.MapFrom(src => src.UserClaims))
            .ForMember(dest => dest.VerificationCode, opt => opt.MapFrom(src => src.VerificationCode))
            .ForMember(dest => dest.VerificationCodeCreateTime, opt => opt.MapFrom(src => src.VerificationCodeCreateTime))
            .ForMember(dest => dest.UserData, opt => opt.MapFrom(src => src.UserData))
            .ForMember(dest => dest.UserContacts, opt => opt.MapFrom <UserContactToListResolver <ApplicationUser> >())
            .ForMember(dest => dest.LastChange, opt => opt.MapFrom(src => src.LastChange))
            .ForMember(dest => dest.ExternalIdentities, opt => opt.Ignore())
            .ForMember(dest => dest.PasswordResetToken, opt => opt.Ignore())
            .ForMember(dest => dest.PasswordResetTokenCreateTime, opt => opt.Ignore())
            .AfterMap((src, dest) =>
            {
                dest.Roles = roleSorter.SortRoles(dest.Roles);
                dest.ResourcePermissions           = resourcePermissionSorter.SortResourcePermissions(dest.ResourcePermissions);
                dest.ResourcePermissionTypeActions = resourcePermissionTypeActionSorter.SortResourcePermissionTypeActions(dest.ResourcePermissionTypeActions);
                dest.UserClaims   = claimSorter.SortClaims(dest.UserClaims);
                dest.UserData     = userDataSorter.SortUserData(dest.UserData);
                dest.UserContacts = contactSorter.SortContacts(dest.UserContacts);
            });

            CreateMap <UserModel, UserData>()
            .ForMember(dest => dest.FirstName, opt => opt.MapFrom(new UserDataStringValueResolver <UserData>(UserDataTypes.FirstName)))
            .ForMember(dest => dest.LastName, opt => opt.MapFrom(new UserDataStringValueResolver <UserData>(UserDataTypes.LastName)))
            .ForMember(dest => dest.FullName, opt => opt.Ignore())
            .ForMember(dest => dest.EmailAddress,
                       opt => opt.MapFrom(new UserContactValueResolver <UserData>(ContactTypeEnumModel.Email)))
            .ForMember(dest => dest.PhoneNumber, opt => opt.MapFrom(new UserContactValueResolver <UserData>(ContactTypeEnumModel.Phone)))
            .ForMember(dest => dest.Muid, opt => opt.Ignore());
        }
예제 #4
0
        public UserContractProfile(IRoleSorter roleSorter)
        {
            CreateMap <UserModel, UserContractBase>()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.MasterUserId, opt => opt.MapFrom(new NullableMasterUserIdDataResolver <UserContractBase>(UserDataTypes.MasterUserId)))
            .ForMember(dest => dest.FirstName, opt => opt.MapFrom(new UserDataStringValueResolver <UserContractBase>(UserDataTypes.FirstName)))
            .ForMember(dest => dest.LastName, opt => opt.MapFrom(new UserDataStringValueResolver <UserContractBase>(UserDataTypes.LastName)))
            .ForMember(dest => dest.ExternalLogin, opt => opt.MapFrom(src => src.ExternalUserLogins))
            .ForMember(dest => dest.PhoneNumber,
                       opt => opt.MapFrom(new UserContactValueResolver <UserContractBase>(ContactTypeEnumModel.Phone)))
            .ForMember(dest => dest.Email,
                       opt => opt.MapFrom(new UserContactValueResolver <UserContractBase>(ContactTypeEnumModel.Email)))
            .ForMember(dest => dest.PhoneLevelOfAssurance,
                       opt => opt.MapFrom(new UserContactLevelOfAssuranceResolver <UserContractBase>(ContactTypeEnumModel.Phone)))
            .ForMember(dest => dest.PhoneNumberConfirmCode,
                       opt => opt.MapFrom(new UserContactConfirmCodeResolver <UserContractBase>(ContactTypeEnumModel.Phone)))
            .ForMember(dest => dest.EmailLevelOfAssurance,
                       opt => opt.MapFrom(new UserContactLevelOfAssuranceResolver <UserContractBase>(ContactTypeEnumModel.Email)))
            .ForMember(dest => dest.EmailConfirmCode,
                       opt => opt.MapFrom(new UserContactConfirmCodeResolver <UserContractBase>(ContactTypeEnumModel.Email)))
            .ForMember(dest => dest.EmailConfirmed,
                       opt => opt.MapFrom(new UserContactConfirmResolver <UserContractBase>(ContactTypeEnumModel.Email)))
            .ForMember(dest => dest.PhoneNumberConfirmed,
                       opt => opt.MapFrom(new UserContactConfirmResolver <UserContractBase>(ContactTypeEnumModel.Phone)))
            .ForMember(dest => dest.SecondName,
                       opt => opt.MapFrom(new UserDataStringValueResolver <UserContractBase>(CustomUserDataTypes.SecondName)))
            .ForMember(dest => dest.FullName,
                       opt => opt.MapFrom(new UserDataStringValueResolver <UserContractBase>(CustomUserDataTypes.FullName)))
            .ForMember(dest => dest.Title, opt => opt.MapFrom(new TitleUserDataResolver <UserContractBase>(CustomUserDataTypes.Title)))
            .ForMember(dest => dest.Prefix, opt => opt.MapFrom(new UserDataStringValueResolver <UserContractBase>(CustomUserDataTypes.Prefix)))
            .ForMember(dest => dest.Suffix, opt => opt.MapFrom(new UserDataStringValueResolver <UserContractBase>(CustomUserDataTypes.Suffix)))
            .ForMember(dest => dest.Roles, opt => opt.MapFrom(src => src.Roles))
            .AfterMap((src, dest) => { dest.Roles = roleSorter.SortRoles(dest.Roles); })
            .ForMember(dest => dest.ValidTwoFactorProviders, opt => opt.Ignore());

            CreateMap <UserBasicInfoModel, BasicUserInfoContract>()
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.Username))
            .ForMember(dest => dest.UserData, opt => opt.MapFrom(new DictionaryUserDataBasicInfoResolver <BasicUserInfoContract>()))
            .ForMember(dest => dest.UserContact,
                       opt => opt.MapFrom(src => src.UserContacts.ToDictionary(k => k.ContactType.ToString(), v => v.Value)));

            CreateMap <UserContractBase, UserModel>() //TODO decide which properties must be transferred to web hub from auth service
            .ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.Roles, opt => opt.MapFrom(src => src.Roles))
            .ForMember(dest => dest.AccessFailedCount, opt => opt.Ignore())
            .ForMember(dest => dest.LastChange, opt => opt.Ignore())
            .ForMember(dest => dest.LockoutEnabled, opt => opt.Ignore())
            .ForMember(dest => dest.LockoutEndDateUtc, opt => opt.Ignore())
            .ForMember(dest => dest.PasswordHash, opt => opt.Ignore())
            .ForMember(dest => dest.SecurityStamp, opt => opt.Ignore())
            .ForMember(dest => dest.TwoFactorEnabled, opt => opt.Ignore())
            .ForMember(dest => dest.TwoFactorProvider, opt => opt.Ignore())
            .ForMember(dest => dest.VerificationCode, opt => opt.Ignore())
            .ForMember(dest => dest.VerificationCodeCreateTime, opt => opt.Ignore())
            .ForMember(dest => dest.ExternalUserLogins, opt => opt.Ignore())
            .ForMember(dest => dest.TwoFactorLogins, opt => opt.Ignore())
            .ForMember(dest => dest.UserClaims, opt => opt.Ignore())
            .ForMember(dest => dest.UserContacts, opt => opt.MapFrom <UserContactToListResolver <UserContractBase> >())
            .ForMember(dest => dest.UserData, opt => opt.MapFrom <UserDataToListResolver <UserContractBase> >())
            .ForMember(dest => dest.ExternalIdentities, opt => opt.Ignore())
            .ForMember(dest => dest.Username, opt => opt.Ignore())
            .ForMember(dest => dest.PasswordResetToken, opt => opt.Ignore())
            .ForMember(dest => dest.PasswordResetTokenCreateTime, opt => opt.Ignore());

            CreateMap <UserModel, UserContract>() //TODO decide which properties must be transferred to web hub from auth service
            .IncludeBase <UserModel, UserContractBase>()
            .ForMember(dest => dest.VerificationCode, opt => opt.MapFrom(src => src.VerificationCode))
            .ForMember(dest => dest.UserName, opt => opt.MapFrom(src => src.Username))
            .ForMember(dest => dest.TwoFactorEnabled, opt => opt.MapFrom(src => src.TwoFactorEnabled))
            .ForMember(dest => dest.TwoFactorProvider, opt => opt.MapFrom(src => src.TwoFactorProvider))
            .ForMember(dest => dest.ValidTwoFactorProviders, opt => opt.Ignore());

            CreateMap <UserModel, UserInfoContract>()
            .ForMember(dest => dest.VerificationCode, opt => opt.MapFrom(src => src.VerificationCode))
            .ForMember(dest => dest.UserId, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.UserName, opt => opt.MapFrom(src => src.Username))
            .ForMember(dest => dest.Email,
                       opt => opt.MapFrom(new UserContactValueResolver <UserInfoContract>(ContactTypeEnumModel.Email)))
            .ForMember(dest => dest.PhoneNumber,
                       opt => opt.MapFrom(new UserContactValueResolver <UserInfoContract>(ContactTypeEnumModel.Phone)))
            .ForMember(dest => dest.EmailConfirmed,
                       opt => opt.MapFrom(new UserContactConfirmResolver <UserInfoContract>(ContactTypeEnumModel.Email)))
            .ForMember(dest => dest.PhoneNumberConfirmed,
                       opt => opt.MapFrom(new UserContactConfirmResolver <UserInfoContract>(ContactTypeEnumModel.Phone)))
            .ForMember(dest => dest.EmailLevelOfAssurance,
                       opt => opt.MapFrom(new UserContactLevelOfAssuranceResolver <UserInfoContract>(ContactTypeEnumModel.Email)))
            .ForMember(dest => dest.PhoneNumberLevelOfAssurance,
                       opt => opt.MapFrom(new UserContactLevelOfAssuranceResolver <UserInfoContract>(ContactTypeEnumModel.Phone)));

            CreateMap <UserContract, UserModel>() //TODO decide which properties must be transferred to web hub from auth service
            .IncludeBase <UserContractBase, UserModel>()
            .ForMember(dest => dest.VerificationCode, opt => opt.MapFrom(src => src.VerificationCode))
            .ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.UserName))
            .ForMember(dest => dest.TwoFactorEnabled, opt => opt.MapFrom(src => src.TwoFactorEnabled))
            .ForMember(dest => dest.TwoFactorProvider, opt => opt.MapFrom(src => src.TwoFactorProvider));

            CreateMap <UserModel, VerifiedUserCreatedContract
                       >() //TODO decide which properties must be transferred to web hub from auth service
            .IncludeBase <UserModel, UserContractBase>()
            .ForMember(dest => dest.UserName, opt => opt.MapFrom(src => src.Username))
            .ForMember(dest => dest.TwoFactorEnabled, opt => opt.MapFrom(src => src.TwoFactorEnabled))
            .ForMember(dest => dest.TwoFactorProvider, opt => opt.MapFrom(src => src.TwoFactorProvider))
            .ForMember(dest => dest.Password, opt => opt.Ignore());

            CreateMap <VerifiedUserCreatedContract, UserModel
                       >() //TODO decide which properties must be transferred to web hub from auth service
            .IncludeBase <UserContractBase, UserModel>()
            .ForMember(dest => dest.Username, opt => opt.MapFrom(src => src.UserName))
            .ForMember(dest => dest.TwoFactorEnabled, opt => opt.MapFrom(src => src.TwoFactorEnabled))
            .ForMember(dest => dest.TwoFactorProvider, opt => opt.MapFrom(src => src.TwoFactorProvider));

            CreateMap <UserModel, UserWithRolesContract>()
            .ForMember(dest => dest.UserId, opt => opt.MapFrom(src => src.Id))
            .ForMember(dest => dest.FirstName, opt => opt.MapFrom(new UserDataStringValueResolver <UserWithRolesContract>(UserDataTypes.FirstName)))
            .ForMember(dest => dest.LastName, opt => opt.MapFrom(new UserDataStringValueResolver <UserWithRolesContract>(UserDataTypes.LastName)))
            .ForMember(dest => dest.Roles, opt => opt.MapFrom(src => src.Roles));
        }