Base solution for your next web application

Activities of "zokho"

Hi, I have been recently googling around looking for some Angular directives to include in my app where came across [https://material.angularjs.org/latest/]) and thought that it would be helpful if is included to the project by default ;)

Thats it :)

that did not work!

Hi, I have got a service in Angular as below:

(function () {
    angular.module('app').factory('workType', ['abp.services.app.workType',
            function (workTypeService) {
                var workType = this;
                
                workType.loadWorkTypes = function () {
                    abp.ui.setBusy(
                        null,
                        workTypeService.getWorkTypeList()
                        .success(function (data) 
                            return data.workTypes;
                        })
                        .error(function (message) {
                            abp.notify.error(message);
                        })
                    );
                };

                return workType;
            }
        ]);
})();

and a controller as

(function () {
    var controllerId = 'app.views.configuration.advertisementFields';
    angular.module('app').controller(controllerId, ['workType',
        function (workTypeService) {
            var vm = this;
            vm.loadWorkTypes = function () {
                var data = workTypeService.loadWorkTypes();
            }
        }
    ]);
})();

Here is my web API code:

public GetWorkTypeListOutput GetWorkTypeList()
        {
            var workTypes = _workTypeRepository.GetAll().ToList();
            var workTypeList = new GetWorkTypeListOutput()
            {
                WorkTypes = Mapper.Map<List<WorkTypeDto>>(workTypes) 
            };

            return workTypeList;
        }

When I call the web api through the angular service defined above, the returned data is undefined! I can see that it hit the web API though. I am pretty sure I am making a mistake in line below within the controller, but do not know how to fix it:

var data = workTypeService.loadWorkTypes();

If I call the Web API directly from the controller it will work fine. but I need to call it through a service/factory.

Hi, I have defined two permissions as bellow:

var advertisement = context.CreatePermission(PermissionNames.Advertisement);

 advertisement.CreateChildPermission(PermissionNames.Advertisement_CreateAd, L("Advertisement.CreateAd"));
 advertisement.CreateChildPermission(PermissionNames.Advertisement_ViewAd, L("Advertisement.ViewAd"));

I am not quite sure how they work though! I am wondering if a role with Advertisement Permission would be able to Create and View ads or I have to grant all three permissions to a role specifically?

Generally, I am wonder how I can grant all defined permissions to an Admin Role efficiently.

Hi, I have got a DTO class defined as:

[AutoMapFrom(typeof(WorkType))]
    public class WorkTypeDto : EntityDto
    {
        public string DisplayName { get; set; }

        public bool IsDeleted { get; set; }

        public int OrderNumber { get; set; }

        public User CreatorUser { get; set; }
    }

[AbpAuthorize("Advertisement")]
        public GetWorkTypeListOutput GetWorkTypeList()
        {
            var workTypes = _workTypeRepository.GetAll().ToList();
            var workTypeList = new GetWorkTypeListOutput()
            {
                WorkTypes = Mapper.Map<List<WorkTypeDto>>(workTypes)
            };
            return workTypeList;
        }

and my Angular code is:

vm.loadWorkTypes = function () {
                abp.ui.setBusy(
                    null,
                    workTypeService.getWorkTypeList()
                    .success(function (data) {
                        vm.gridOptions.data = data.workTypes;
                        
                    })
                    .error(function (message) {
                        alert(message);
                    })
                );
            };

it is properly populate the DTO to be passed to the Angular, but for some reason it fails without showing any descriptive error message as: [object obeject] and Internal error occurred!

I narrowed down the issue and found out that the CreatorUser property is causing it. If I change its type from User class to string that will work. Any thought?

Hi Thanks for your solution and sorry for the late response. Actually, I have replied but not sure where it has gone! I have got 2 questions followed by a request regarding your approach:

  1. When you say a Controller, do you mean an API within the Api project or a normal Controller and an action defined in the Web project?
  2. Why are you converting the uploaded file to String?! Do you save the converted string in DB or store in a folder?
  3. Could you please send the Angular code you use to call the Controller and the service?

Thanks

Hi, I have just created a template through the aspnetboilerplate website and right after I have updated all libraries via Nuget update. In the created template the Configuration class extended ISupportSeedMode which seems was removed from the updated version of Abp.Zero.EntityFramework.

  • In the first place, I wonder why the newly created template not referring to the most recent versions of DLLs!?
  • how should I fix the problem? Should I create another template and this time not update the DLLs?
  • where can see the changes (or fixes) in each versions of ABP framework before getting them updated?

Regards,

Question

Hi, Does anyone know that if its feasible to upload files using Dtos in the Application layer? If yes, can I have a sample code which shows how to define properties in DTO classes and how to call the service from AngularJS?

Thanks,

Hi Ibrahim, Thanks again for your advice. Now I have got another question: I am using [https://github.com/danialfarid/ng-file-upload]) to upload files via Angular. I am using the code below to send userId as a form data multipart along with the uploaded file to create a folder as per its value and then save the uploaded file:

file.upload = Upload.upload({
      url: '/api/File/Upload',
      data: {userId: appSession.user.id, file: file}
    });

For the whole past day I have been struggling to fetch the form-data and get the posted userId so I could create a folder prior saving the file. Do you have any advice on:

  1. Am I doing the right thing? I mean, do I really need to pass the userId along with the file or I could retrieve it in the WebApi project side somehow?!
  2. I have just come across this parser [https://github.com/Vodurden/Http-Multipart-Data-Parser]) which would let to parse the form-data request (have not tried that though as yet!)
  3. Is there a such parser within the ABP Framework so I could use rather using the above parser?

I really appreciate your advice and thanks in advance... ;)

Hi, I have created an uploading WebApi in the WebApi project. I am using the Api from the Web project to upload files via AngularJS. I have also created a directory and named it as "Document". Here are my wonders:

Where should I define the Document folder (in the WebApi project or the Web one)? I assume it should be in the Web project where the client-side code resides. If my guess is true, then do not know how to point to a folder in the Web project from the WebApi project to save the file in?!

Thanks for your tips and advice in advance ... ;)

Showing 51 to 60 of 66 entries