Hi,
I'm new to ABP framework and need some help regarding best practices to make changes in ABP modules code. We need to extend one of the methods (specifically CreateAsync) to publish another event to Distributed event bus service, upon new user creation. We have the module (Identity.pro) source code; however, I'm not sure if it is a good idea to include the whole module source code into our project, instead I'm looking for the best practices on how to do that. Is there any better way to make such changes without making the whole module source code part of your project?
Thanks, Moin
I think you must be interested in the two files:
public class Auth0UsersManagementModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
Configure<Auth0ConnectionOptions>(
configuration.GetSection("Auth0"));
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var service = context
.ServiceProvider
.GetRequiredService<Auth0UsersManagementInit>();
service.Initialize();
}
}
public class Auth0UsersManagementModuleAutoMapperProfile : Profile
{
public Auth0UsersManagementModuleAutoMapperProfile()
{
CreateMap<UserDto, UserCreateRequest>()
//.ForMember(dest => dest.Prop, opt => opt.Ignore())
//.ForMember(dest => dest.Prop, opt => opt.MapFrom(src => src.Prop))
.AfterMap((src, dest) => {
dest.Connection = "Username-Password-Authentication";
});
CreateMap<UserDto, UserUpdateRequest>()
.ForMember(dest => dest.Password, opt => opt.Ignore())
.AfterMap((src, dest) => {
dest.Connection = "Username-Password-Authentication";
});
CreateMap<User, UserDto>()
.ForMember(dest => dest.Password, opt => opt.Ignore())
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.UserId));
CreateMap<User, UserUpdateRequest>();
}
}
Mapping is called as:
var request = ObjectMapper.Map<UserDto, UserCreateRequest>(user);
Yes, already added; as I said it was working like a charm and then suddenly stopped working.
I have added an object mapper in my custom module as below:
public class Auth0UsersManagementModuleAutoMapperProfile : Profile
{
public Auth0UsersManagementModuleAutoMapperProfile()
{
CreateMap<UserDto, UserCreateRequest>()
//.ForMember(dest => dest.Prop, opt => opt.Ignore())
//.ForMember(dest => dest.Prop, opt => opt.MapFrom(src => src.Prop))
.AfterMap((src, dest) => {
dest.Connection = "Username-Password-Authentication";
});
CreateMap<UserDto, UserUpdateRequest>()
.ForMember(dest => dest.Password, opt => opt.Ignore())
.AfterMap((src, dest) => {
dest.Connection = "Username-Password-Authentication";
});
CreateMap<User, UserDto>()
.ForMember(dest => dest.Password, opt => opt.Ignore())
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.UserId));
CreateMap<User, UserUpdateRequest>();
}
}
The code was working fine and now suddently have stopped working and throwing exception as: "AutoMapperMappingException: Missing type map configuration or unsupported mapping."
Really annoying to see nonderministic code behavior. I have been using AutoMapper since quite some and I'm 100% sure about the mapping is there in code, however, still no luck.
Hi,
I'm adding a new field in an existing table, and want to add a lookup table for it. Lookup table will have a few text entries a user can select from. One way I can think of adding a Lookup table is to use abp suite scaffolding, however, it generates a lot more code that looks an over kill for a table like that merely being setup once and will be update probably in years. Is there any simpler way for this in abp framework?
Thanks
Hi Mahmut,
I'm talking about here extending an existing with new functionality, precisely in this case, adding another tab to User update modal. Can you provide some more concrete example how to do it without the source code?
Thanks
Hi,
I checked that the source code is not available to us on our license tier; is there any other way to accomplish this without buying the source code?
Thanks
Hi,
We'd like to add a new entity (say User additional detail) in the system and create a foreign key relation with the User entity. It is fairly easy through scaffolding using abp suite, however, it creates an entirely new set of pages in the system which is not an elegant way as if you want to add additional details while creating a user, you'd have to navigate out on a separate screen and add it there; this back & forth navigation to different pages for achieving a single goal is not a desirable way anyone would want to go with. Instead of it while creating a new user we'd like to add the additional details right there in the model (preferably in a tab) as shown below image. Please let us know how this can be achieved.
Thanks