11using AutoMapper ;
2+ using IdentityServer4 . Models ;
23using Jp . Application . ViewModels ;
4+ using Jp . Application . ViewModels . ApiResouceViewModels ;
5+ using Jp . Application . ViewModels . ClientsViewModels ;
6+ using Jp . Application . ViewModels . IdentityResourceViewModels ;
7+ using Jp . Application . ViewModels . RoleViewModels ;
8+ using Jp . Application . ViewModels . UserViewModels ;
9+ using Jp . Domain . Commands . ApiResource ;
10+ using Jp . Domain . Commands . Client ;
11+ using Jp . Domain . Commands . IdentityResource ;
12+ using Jp . Domain . Commands . PersistedGrant ;
13+ using Jp . Domain . Commands . Role ;
314using Jp . Domain . Commands . User ;
415using Jp . Domain . Commands . UserManagement ;
516
@@ -9,26 +20,79 @@ public class ViewModelToDomainMappingProfile : Profile
920 {
1021 public ViewModelToDomainMappingProfile ( )
1122 {
23+ /*
24+ * Persisted grant
25+ */
26+ CreateMap < RemovePersistedGrantViewModel , RemovePersistedGrantCommand > ( ) . ConstructUsing ( c => new RemovePersistedGrantCommand ( c . Key ) ) ;
27+
1228 /*
1329 * User Creation Commands
1430 */
15- CreateMap < UserViewModel , RegisterNewUserCommand > ( ) . ConstructUsing ( c => new RegisterNewUserCommand ( c . Username , c . Email , c . Name , c . PhoneNumber , c . Password , c . ConfirmPassword ) ) ;
31+ CreateMap < RegisterUserViewModel , RegisterNewUserCommand > ( ) . ConstructUsing ( c => new RegisterNewUserCommand ( c . Username , c . Email , c . Name , c . PhoneNumber , c . Password , c . ConfirmPassword ) ) ;
1632 CreateMap < SocialViewModel , RegisterNewUserWithoutPassCommand > ( MemberList . Source ) . ConstructUsing ( c => new RegisterNewUserWithoutPassCommand ( c . Email , c . Email , c . Name , c . Picture , c . Provider , c . ProviderId ) ) ;
17- CreateMap < UserViewModel , RegisterNewUserWithProviderCommand > ( ) . ConstructUsing ( c => new RegisterNewUserWithProviderCommand ( c . Username , c . Email , c . Name , c . PhoneNumber , c . Password , c . ConfirmPassword , c . Picture , c . Provider , c . ProviderId ) ) ;
33+ CreateMap < RegisterUserViewModel , RegisterNewUserWithProviderCommand > ( ) . ConstructUsing ( c => new RegisterNewUserWithProviderCommand ( c . Username , c . Email , c . Name , c . PhoneNumber , c . Password , c . ConfirmPassword , c . Picture , c . Provider , c . ProviderId ) ) ;
1834 CreateMap < ForgotPasswordViewModel , SendResetLinkCommand > ( ) . ConstructUsing ( c => new SendResetLinkCommand ( c . UsernameOrEmail , c . UsernameOrEmail ) ) ;
1935 CreateMap < ResetPasswordViewModel , ResetPasswordCommand > ( ) . ConstructUsing ( c => new ResetPasswordCommand ( c . Password , c . ConfirmPassword , c . Code , c . Email ) ) ;
2036 CreateMap < ConfirmEmailViewModel , ConfirmEmailCommand > ( ) . ConstructUsing ( c => new ConfirmEmailCommand ( c . Code , c . Email ) ) ;
2137
22-
2338 /*
2439 * User Management commands
2540 */
26- CreateMap < ProfileViewModel , UpdateProfileCommand > ( ) . ConstructUsing ( c => new UpdateProfileCommand ( c . Id , c . Url , c . Bio , c . Company , c . JobTitle , c . Name , c . PhoneNumber ) ) ;
41+ CreateMap < UserViewModel , UpdateProfileCommand > ( ) . ConstructUsing ( c => new UpdateProfileCommand ( c . Id , c . Url , c . Bio , c . Company , c . JobTitle , c . Name , c . PhoneNumber ) ) ;
42+ CreateMap < UserViewModel , UpdateUserCommand > ( ) . ConstructUsing ( c => new UpdateUserCommand ( c . Email , c . UserName , c . Name , c . PhoneNumber , c . EmailConfirmed , c . PhoneNumberConfirmed , c . TwoFactorEnabled , c . LockoutEnd , c . LockoutEnabled , c . AccessFailedCount ) ) ;
2743 CreateMap < ProfilePictureViewModel , UpdateProfilePictureCommand > ( ) . ConstructUsing ( c => new UpdateProfilePictureCommand ( c . Id ) ) ;
28-
29- CreateMap < ChangePasswordViewModel , ChangePasswordCommand > ( ) . ConstructUsing ( c => new ChangePasswordCommand ( c . Id , c . OldPassword , c . NewPassword , c . ConfirmPassword ) ) ;
44+ CreateMap < ChangePasswordViewModel , ChangePasswordCommand > ( ) . ConstructUsing ( c => new ChangePasswordCommand ( c . Id , c . OldPassword , c . NewPassword , c . ConfirmPassword ) ) ;
3045 CreateMap < SetPasswordViewModel , SetPasswordCommand > ( ) . ConstructUsing ( c => new SetPasswordCommand ( c . Id , c . NewPassword , c . ConfirmPassword ) ) ;
3146 CreateMap < RemoveAccountViewModel , RemoveAccountCommand > ( ) . ConstructUsing ( c => new RemoveAccountCommand ( c . Id ) ) ;
47+ CreateMap < SaveUserClaimViewModel , SaveUserClaimCommand > ( ) . ConstructUsing ( c => new SaveUserClaimCommand ( c . Username , c . Type , c . Value ) ) ;
48+ CreateMap < RemoveUserClaimViewModel , RemoveUserClaimCommand > ( ) . ConstructUsing ( c => new RemoveUserClaimCommand ( c . Username , c . Type ) ) ;
49+ CreateMap < RemoveUserRoleViewModel , RemoveUserRoleCommand > ( ) . ConstructUsing ( c => new RemoveUserRoleCommand ( c . Username , c . Role ) ) ;
50+ CreateMap < SaveUserRoleViewModel , SaveUserRoleCommand > ( ) . ConstructUsing ( c => new SaveUserRoleCommand ( c . Username , c . Role ) ) ;
51+ CreateMap < RemoveUserLoginViewModel , RemoveUserLoginCommand > ( ) . ConstructUsing ( c => new RemoveUserLoginCommand ( c . Username , c . LoginProvider , c . ProviderKey ) ) ;
52+ CreateMap < AdminChangePasswordViewodel , AdminChangePasswordCommand > ( ) . ConstructUsing ( c => new AdminChangePasswordCommand ( c . Password , c . ConfirmPassword , c . Username ) ) ;
53+
54+ /*
55+ * Client commands
56+ */
57+ CreateMap < Client , UpdateClientCommand > ( ) . ConstructUsing ( c => new UpdateClientCommand ( c ) ) ;
58+ CreateMap < RemoveClientSecretViewModel , RemoveClientSecretCommand > ( ) . ConstructUsing ( c => new RemoveClientSecretCommand ( c . Id , c . ClientId ) ) ;
59+ CreateMap < RemovePropertyViewModel , RemovePropertyCommand > ( ) . ConstructUsing ( c => new RemovePropertyCommand ( c . Id , c . ClientId ) ) ;
60+ CreateMap < SaveClientSecretViewModel , SaveClientSecretCommand > ( ) . ConstructUsing ( c => new SaveClientSecretCommand ( c . ClientId , c . Description , c . Value , c . Type , c . Expiration , ( int ) c . Hash . GetValueOrDefault ( HashType . Sha256 ) ) ) ;
61+ CreateMap < SaveClientPropertyViewModel , SaveClientPropertyCommand > ( ) . ConstructUsing ( c => new SaveClientPropertyCommand ( c . ClientId , c . Key , c . Value ) ) ;
62+ CreateMap < SaveClientClaimViewModel , SaveClientClaimCommand > ( ) . ConstructUsing ( c => new SaveClientClaimCommand ( c . ClientId , c . Type , c . Value ) ) ;
63+ CreateMap < RemoveClientClaimViewModel , RemoveClientClaimCommand > ( ) . ConstructUsing ( c => new RemoveClientClaimCommand ( c . Id , c . ClientId ) ) ;
64+ CreateMap < RemoveClientViewModel , RemoveClientCommand > ( ) . ConstructUsing ( c => new RemoveClientCommand ( c . ClientId ) ) ;
65+ CreateMap < CopyClientViewModel , CopyClientCommand > ( ) . ConstructUsing ( c => new CopyClientCommand ( c . ClientId ) ) ;
66+ CreateMap < SaveClientViewModel , SaveClientCommand > ( ) . ConstructUsing ( c => new SaveClientCommand ( c . ClientId , c . ClientName , c . ClientUri , c . LogoUri , c . Description , c . ClientType ) ) ;
67+
68+ /*
69+ * Identity Resource commands
70+ */
71+ CreateMap < IdentityResource , RegisterIdentityResourceCommand > ( ) . ConstructUsing ( c => new RegisterIdentityResourceCommand ( c ) ) ;
72+ CreateMap < IdentityResource , UpdateIdentityResourceCommand > ( ) . ConstructUsing ( c => new UpdateIdentityResourceCommand ( c ) ) ;
73+ CreateMap < RemoveIdentityResourceViewModel , RemoveIdentityResourceCommand > ( ) . ConstructUsing ( c => new RemoveIdentityResourceCommand ( c . Name ) ) ;
74+
75+ /*
76+ * Api Resource commands
77+ */
78+ CreateMap < ApiResource , RegisterApiResourceCommand > ( ) . ConstructUsing ( c => new RegisterApiResourceCommand ( c ) ) ;
79+ CreateMap < ApiResource , UpdateApiResourceCommand > ( ) . ConstructUsing ( c => new UpdateApiResourceCommand ( c ) ) ;
80+ CreateMap < RemoveApiResourceViewModel , RemoveApiResourceCommand > ( ) . ConstructUsing ( c => new RemoveApiResourceCommand ( c . Name ) ) ;
81+
82+ CreateMap < SaveApiSecretViewModel , SaveApiSecretCommand > ( ) . ConstructUsing ( c => new SaveApiSecretCommand ( c . ResourceName , c . Description , c . Value , c . Type , c . Expiration , ( int ) c . Hash . GetValueOrDefault ( HashType . Sha256 ) ) ) ;
83+ CreateMap < RemoveApiSecretViewModel , RemoveApiSecretCommand > ( ) . ConstructUsing ( c => new RemoveApiSecretCommand ( c . Id , c . ResourceName ) ) ;
84+
85+ CreateMap < RemoveApiScopeViewModel , RemoveApiScopeCommand > ( ) . ConstructUsing ( c => new RemoveApiScopeCommand ( c . Id , c . ResourceName ) ) ;
86+ CreateMap < SaveApiScopeViewModel , SaveApiScopeCommand > ( ) . ConstructUsing ( c => new SaveApiScopeCommand ( c . ResourceName , c . Name , c . Description , c . DisplayName , c . Emphasize , c . ShowInDiscoveryDocument , c . UserClaims ) ) ;
87+
88+ /*
89+ * Role commands
90+ */
91+ CreateMap < RemoveRoleViewModel , RemoveRoleCommand > ( ) . ConstructUsing ( c => new RemoveRoleCommand ( c . Name ) ) ;
92+ CreateMap < SaveRoleViewModel , SaveRoleCommand > ( ) . ConstructUsing ( c => new SaveRoleCommand ( c . Name ) ) ;
93+ CreateMap < UpdateRoleViewModel , UpdateRoleCommand > ( ) . ConstructUsing ( c => new UpdateRoleCommand ( c . Name , c . OldName ) ) ;
94+ CreateMap < RemoveUserFromRoleViewModel , RemoveUserFromRoleCommand > ( ) . ConstructUsing ( c => new RemoveUserFromRoleCommand ( c . Role , c . Username ) ) ;
95+
3296 }
3397 }
3498}
0 commit comments