Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "fastsoft"

Answer

thank you very much aaron. I solved problem.

Answer

PersonAppService.cs

namespace OKYS.Person.Services
{
    public class PersonAppService : OKYSFastAppServiceBase, IPersonAppService
    {
        private readonly IRepository<VPersonInfo> _personRepository;

        public PersonAppService() : base()
        {
            _personRepository = new Repository<VPersonInfo>();
        }
        //Methods
        [HttpPost]
        public async Task<PagedResultDto<VPersonInfo>> GetData(FGetEntityExpression searchParams)
        {
            return await _personRepository.GetDataWithPaging(searchParams);
        }

        public async Task<VPersonInfo> SelectById(int pkId)
        {
            return await _personRepository.Select(pkId);
        }

        public async Task<VPersonInfo> Select(List<FSearchExpression> expressionList)
        {
            return await _personRepository.Select(expressionList);
        }

        [HttpDelete]
        public async Task<ProcessResult> DeleteById(int pkId)
        {
            return await _personRepository.Delete(pkId);
        }

        [HttpPost]
        public async Task<ProcessResult> Delete(VPersonInfo personInfo)
        {
            return await _personRepository.Delete(personInfo);
        }

        public async Task<VPersonInfo> Insert(VPersonInfo personInfo)
        {

            long? userId = base.AbpSession.UserId; //when called from web app userId is not null. But when ı call from StudentAppService.cs userId gets null.

            personInfo.OrganizationId = new OrganizationAppService().GetUserOrganizationData(userId);

            return await _personRepository.Insert(personInfo);
        }

        [HttpPost]
        public async Task<VPersonInfo> Update(VPersonInfo personInfo)
        {
            return await _personRepository.Update(personInfo);
        }


    }
}

StudentRegisterService.cs

namespace OKYS.Student.Services
{
    public class StudentAppService : OKYSFastAppServiceBase, IStudentAppService
    {
        private readonly IRepository<VStudentInfo> _StudentRepository;

        public StudentAppService() : base()
        {
            _StudentRepository = new Repository<VStudentInfo>();
        }
        //Methods
        [HttpPost]
        public async Task<PagedResultDto<VStudentInfo>> GetData(FGetEntityExpression searchParams)
        {
            return await _StudentRepository.GetDataWithPaging(searchParams);
        }

        public async Task<VStudentInfo> SelectById(int pkId)
        {
            return await _StudentRepository.Select(pkId);
        }

        public async Task<VStudentInfo> Select(List<FSearchExpression> expressionList)
        {
            return await _StudentRepository.Select(expressionList);
        }

        [HttpDelete]
        public async Task<ProcessResult> DeleteById(int pkId)
        {
            return await _StudentRepository.Delete(pkId);
        }

        [HttpPost]
        public async Task<ProcessResult> Delete(VStudentInfo StudentInfo)
        {
            return await _StudentRepository.Delete(StudentInfo);
        }

        public async Task<VStudentInfo> Insert(VStudentInfo StudentInfo)
        {
            return await _StudentRepository.Insert(StudentInfo);
        }

        [HttpPost]
        public async Task<VStudentInfo> Update(VStudentInfo StudentInfo)
        {
            return await _StudentRepository.Update(StudentInfo);
        }

        public async Task<ProcessResult> RegisterStudent(StudentInpuOutputDto input)
        {
            ProcessResult result = new ProcessResult(true);

            input.StudentPerson = await new PersonAppService().Insert(input.StudentPerson);
            input.Student.PersonId = input.StudentPerson.PersonId;
            input.Student = await new StudentAppService().Insert(input.Student);
            result.RecordID = input.Student.StudentId;
            return result;
        }

    }
}
Answer

Hi.

Yes How can i call AppService1 in your application like @aaron asked ? I'm using web app(angular).

For Example: ı have a PersonAppService. İt has insert,update,delete,get methodts for using clients. Same time I need to use the organizationId to which the session user belongs when I register.

Everything is right here. I can that when ı call insert or update method from client. I can see user from base.GetCurrentUser();

But, I have a second app service. It name is StudentService(has insert,update,delete, get methods). Student table is relasionship to person table with PersonId. When I want to save the student I will add the person first and then add the PersonId to student. So ı have to use PersonServiceApp in SetudentServiceApp. I think this way bast way for this demand.

as a result have can i get CurrentUser when user AppService in another AppService.

Thanks.

Answer

there is no one to answer? I need to solve this problem. please

Answer

I have same problem.

I have to AppService. When ı call service methot from angular client ı can see current user base.GetCurrentUser(). But ı call service method from another service base.GetCurrentUser() return null. Please help. thanks.

I'm getting the same error. I copied xxx\angular\src\app\admin\audit-logs\audit-logs.component.ts and changed own component.

.ts File

import { NgModule } from '@angular/core';
import { Component, AfterViewInit, Injector, ViewEncapsulation, ViewChild } from '@angular/core';
import { NotifyService } from '@abp/notify/notify.service';
import { AppComponentBase } from '@shared/common/app-component-base';
import { appModuleAnimation } from '@shared/animations/routerTransition';

import { DataTable } from 'primeng/components/datatable/datatable';
import { Paginator } from 'primeng/components/paginator/paginator';
import { LazyLoadEvent } from 'primeng/components/common/lazyloadevent';


import { OgrenciServiceProxy, VOgrenciInfo, PagedResultDtoOfVOgrenciInfo, FGetEntityExpression, FSearchExpression } from '@shared/service-proxies/service-proxies';


@Component({
    templateUrl: './ogrenci-list.component.html',
    encapsulation: ViewEncapsulation.None,
    animations: [appModuleAnimation()]
})


export class OgrenciListComponent extends AppComponentBase {

    @ViewChild('dataTable') dataTable: DataTable;
    @ViewChild('paginator') paginator: Paginator;

    ogrenciList: VOgrenciInfo[] = [];
    searchExp = new FGetEntityExpression();

    fSearchExpression = new FSearchExpression();


    constructor(
        injector: Injector,
        private _ogrenciService: OgrenciServiceProxy,
        private _notifyService: NotifyService
    ) {
        super(injector);
        this.searchExp.maxResultCount = 20;
        this.searchExp.skipCount = 0;

        this.primengDatatableHelper.totalRecordsCount = 0;

        this.fSearchExpression.propName = "OgrenciId";
        this.fSearchExpression.searchOperator = 4;
        this.fSearchExpression.searchAndOrOperator = 0;
        this.fSearchExpression.value1 = 4;
        this.searchExp.expressionList = new Array<FSearchExpression>();
        this.searchExp.expressionList.push(this.fSearchExpression);


    }

    getOgrenci(event?: LazyLoadEvent) {

        this.primengDatatableHelper.showLoadingIndicator();

        this._ogrenciService.getData(this.searchExp).subscribe(result => {
            this.ogrenciList = result.items;
            this.primengDatatableHelper.records = result.items;
            this.primengDatatableHelper.totalRecordsCount = result.items.length;
            this.primengDatatableHelper.hideLoadingIndicator();
        });

    }

}

.html file

<div [@routerTransition]>
    <div class="row margin-bottom-5">
        <div class="col-xs-6">
            <div class="page-head">
                <div class="page-title">
                    <h1>
                        <span>{{l("Student")}}</span>
                    </h1>
                </div>
            </div>
        </div>
        <div class="col-xs-6 text-right">
        </div>
    </div>

    <div class="portlet light margin-bottom-0">
        <div class="portlet-body">
            <div class="primeng-datatable-container" [busyIf]="primengDatatableHelper.isLoading">

         
                <div class="primeng-paging-container">
                    <p-paginator rows="{{primengDatatableHelper.defaultRecordsCountPerPage}}"
                                 #paginator
                                 (onPageChange)="getOgrenci($event)"
                                 [totalRecords]="primengDatatableHelper.totalRecordsCount"
                                 [rowsPerPageOptions]="primengDatatableHelper.predefinedRecordsCountPerPage">
                    </p-paginator>
                    <span class="total-records-count">
                        {{l('TotalRecordsCount', primengDatatableHelper.totalRecordsCount)}}
                    </span>
                </div>
            </div>
        </div>

    </div>


</div>
Showing 1 to 6 of 6 entries