コード例 #1
0
        public async Task <GetAgentCarriersManagementDto> getAgentCarriersManagement(int pageNo, string filter, int parentId, string parentTitle)
        {
            if (parentId == 0)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
            }

            GetAgentCarriersManagementDto oGetAgentCarriersManagementDto =
                await _AgentCarrierService.getAgentCarriersManagement(new GridChildInitialDto
            {
                recordCountPerPage = Setting.RECORD_COUNT_PAGE,
                pageNo             = pageNo,
                filter             = filter,
                userId             = Setting.payloadDto.userId,
                parentId           = parentId,
                parentTitle        = parentTitle
            });

            if (oGetAgentCarriersManagementDto == null)
            {
                throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound));
            }

            return(oGetAgentCarriersManagementDto);
        }
コード例 #2
0
ファイル: AgentCarrierService.cs プロジェクト: azaryoun/MTFS
        public async Task <GetAgentCarriersManagementDto> getAgentCarriersManagement(GridChildInitialDto gridInitialDto)
        {
            int pageNo = gridInitialDto.pageNo;

            if (gridInitialDto.pageNo < 1)
            {
                pageNo = 1;
            }

            IQueryable <AgentCarrier> oAgentCarriers = _AgentCarriers.Include(i => i.carrier)
                                                       .Include(i => i.location)
                                                       .Where(i => i.agentId == gridInitialDto.parentId)
                                                       .AsQueryable();

            if (!string.IsNullOrEmpty(gridInitialDto.filter))
            {
                oAgentCarriers = oAgentCarriers
                                 .Where(w => w.carrier.fullName.Contains(gridInitialDto.filter) == true);
            }

            int totalRecordCount = await oAgentCarriers.AsNoTracking().CountAsync();

            GetAgentCarriersManagementDto oAgentCarriersManagDto = new GetAgentCarriersManagementDto();

            if (totalRecordCount != 0)
            {
                int totalPages = (int)Math.Ceiling((double)totalRecordCount / gridInitialDto.recordCountPerPage);

                if (pageNo > totalPages)
                {
                    pageNo = totalPages;
                }


                oAgentCarriersManagDto.getAgentCarriersDto = Mapper.Map <IEnumerable <AgentCarrier>, List <GetAgentCarriersDto> >
                                                                 (await oAgentCarriers.GetPageRecords(pageNo, gridInitialDto.recordCountPerPage).ToListAsync());

                oAgentCarriersManagDto.currentPage      = pageNo;
                oAgentCarriersManagDto.totalRecordCount = totalRecordCount;
            }
            oAgentCarriersManagDto.title = gridInitialDto.parentTitle;
            return(oAgentCarriersManagDto);
        }