Search code examples
c#asp.net-coreaspnetboilerplate

Creating dynamic JavaScript proxy for custom ApplicationService


I've read the ABP documentation.

Here is my solution architecture for my new project based on the ABP Framework. First of all, I want to ask if there is anything wrong with this design?

enter image description here

I've registered all my app services to IocManager in my Holitera.ApplicationModule. So now I can call my app services from MVC controllers. RegionAppService is my new AppService here.

Here is the registration:

enter image description here

And my RegionAppService class:

public class RegionAppService : AsyncCrudAppService<Region, RegionDto,int>, IRegionAppService
{
    private readonly IRepository<Region> _regionRepository;
    public RegionAppService(IRepository<Region> regionRepository) :
        base(regionRepository)
    {
        CreatePermissionName = "CreateRegionPermission";
        _regionRepository = regionRepository;
    }
}

Now I want to create a CRUD Razor page like the Roles view in the default template. But I couldn't register my custom RegionAppService to the JavaScript proxy services.

Do I need a dynamic Web API module to do that? Is that necessary? If it is, then how are Role, User, Customer, Account services registered to the dynamic JS proxy? I couldn't find the configuration for that. As much as I know there is no configuration for dynamic Web API module in the default MVC template? So I don't have an API module yet.

I'm going to need a dynamic JavaScript module later, but not now. First, I just want to handle this.

And by the way, what is the difference between dynamic AJAX call methods and dynamic Web API module? Are they same or if not, how?

Thanks :)


Solution

  • anything wrong with this design?

    Entity and DomainService go in Core project. Dto and AppService go in Application project.
    You can read about NLayer Architecture.

    It's how the other services are discovered, and the right approach.

    Do i need dynamic web api module to do that? Is that neccessary?

    No.

    how are Role, User, Customer, Account services are registered to dynamic js proxy? I couldn't find the configuration for that. As much as i know there is no configuration for dynamic api module in default mvc template?

    It's done in YourProjectNameWebCoreModule. You can create controllers for additional assemblies:

    Configuration.Modules.AbpAspNetCore()
        .CreateControllersForAppServices(
            typeof(RegionAppService).GetAssembly()
        );