Open Closed

Help I can't access my custom Application Services from JQuery #6455


0
martin created

So this guide explains that I can setup an application service and it can then be accessed.

https://aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API

Problem I have is that the Application Services which were created by the RAD tool are available in the generated JQuery files. But the Application Services I added later aren't, what do I need to update so they are available ?

Keep in mind I am having existing problems accessing abp.custom.EntityHistory so maybe they are related ?


7 Answer(s)
  • 0
    maliming created

    Can you talk specifically about the problem? If there are screenshots this is better.

  • 0
    ryancyq created

    Also, the document you provided was for aspnet mvc web api.

    For aspnet core, see https://aspnetboilerplate.com/Pages/Documents/AspNet-Core#application-services-as-controllers

  • 0
    martin created

    So here is the Interface that was generated by the RAD tool (with a small edit afterwards)

     public interface ISuperFundsAppService : IApplicationService 
        {
            Task<PagedResultDto<GetSuperFundForView>> GetAll(GetAllSuperFundsInput input);
    		Task<GetSuperFundForEditOutput> GetSuperFundForEdit(EntityDto<long> input);
    		Task CreateOrEdit(CreateOrEditSuperFundDto input);
    		Task Delete(EntityDto<long> input);
    		Task<FileDto> GetSuperFundsToExcel(GetAllSuperFundsForExcelInput input);
            Task<List<ComboboxItemDto>> GetSuperComboItems(long? selectedId = null);
        }
    

    I then created a new interface for processing dropdowns

      public interface ISuperFundLookupAppService : IApplicationService
        {
            List<ComboboxItemDto> GetSuperFundTypeComboItems(int? selectedId = null);
            string GetSuperFundTypeFromID(int inputId);
    
            List<ComboboxItemDto> GetSuperFundPaymentFrequencyComboItems(int? selectedId = null);
            string GetSuperFundPaymentFrequencyFromID(int inputId);
    
            List<ComboboxItemDto> GetSuperFundPaymentMethodComboItems(int? selectedId = null);
            string GetSuperFundPaymentMethodFromID(int inputId);
        }
    

    I added the new controller to the MVC - Controller

      [Area("App")]
        [AbpMvcAuthorize(AppPermissions.Pages_SuperFunds)]
        public class SuperFundsController : epaydayControllerBase
        {
            private readonly ISuperFundsAppService _superFundsAppService;
            private readonly ISuperFundLookupAppService _superFundLookupAppService;
            private readonly IValueTranslationAppService _valueTranslationAppService;
    
            public SuperFundsController(
                ISuperFundsAppService superFundsAppService,
                ISuperFundLookupAppService superFundLookupAppService,
                IValueTranslationAppService valueTranslationAppService)
            {
                _superFundsAppService = superFundsAppService;
                _superFundLookupAppService = superFundLookupAppService;
                _valueTranslationAppService = valueTranslationAppService;
            }
    

    Part of the index.js

    (function () {
        $(function () {       
            var _$superFundsTable = $('#SuperFundsTable');
            var _superFundsService = abp.services.app.superFunds;
    		var _entityTypeFullName = 'epayday.Epayday.SuperFunds.SuperFund';
    

    But I can't access the lookup service with something like

    abp.services.app.superFundLookup
    
  • 0
    martin created

    Sorry about the confusion, but the original question title is incorrect and I have changed that. What I am trying to work is how do make my custom Application Services accessable to my .js files ? I am still a bit confused since only the Services created by the RAD tool work in JQuery. I know it will be something simple but the more I read the more it makes no sense to me.

  • 0
    maliming created

    @martin Can you use the DEMO project to reproduce the problem you encountered and then share the project? My email: liming.ma@volosoft.com

  • 0
    ryancyq created

    Hi @martin, i believe you are refering to javascript proxies that generated by the framework automatically.

    You need to add RemoteService to your MVC controller.

    See https://aspnetboilerplate.com/Pages/Documents/AspNet-Core#client-proxies

  • 0
    maliming created

    Has been solved remotely.