示例#1
0
        public async Task <GetNegotiationplansManagementDto> getNegotiationplansManagement(GridChildInitialDto gridInitialDto)
        {
            int pageNo = gridInitialDto.pageNo;

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

            IQueryable <Negotiationplan> oNegotiationplans = _Negotiationplans.Where(i => i.negotiationId == gridInitialDto.parentId).AsQueryable();

            if (!string.IsNullOrEmpty(gridInitialDto.filter))
            {
                oNegotiationplans = oNegotiationplans
                                    .Where(w => w.planName.Contains(gridInitialDto.filter) == true);
            }

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

            GetNegotiationplansManagementDto oGetNegotiationplansManagementDto = new GetNegotiationplansManagementDto();

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

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


                oGetNegotiationplansManagementDto.getNegotiationplansDto = Mapper.Map <IEnumerable <Negotiationplan>, List <GetNegotiationplansDto> >
                                                                               (await oNegotiationplans.GetPageRecords(pageNo, gridInitialDto.recordCountPerPage).ToListAsync());

                oGetNegotiationplansManagementDto.currentPage      = pageNo;
                oGetNegotiationplansManagementDto.totalRecordCount = totalRecordCount;
            }

            oGetNegotiationplansManagementDto.title           = gridInitialDto.parentTitle;
            oGetNegotiationplansManagementDto.parent_ParentId = gridInitialDto.parentId;

            return(oGetNegotiationplansManagementDto);
        }
        public async Task <GetNegotiationplansManagementDto> getNegotiationplansManagement(int pageNo, string filter, int parentId, string parentTitle)
        {
            GetNegotiationplansManagementDto oNegotiationplansManagementDto = await
                                                                              _NegotiationplanService.getNegotiationplansManagement(new GridChildInitialDto
            {
                recordCountPerPage = Setting.RECORD_COUNT_PAGE,
                pageNo             = pageNo,
                filter             = filter,
                userId             = Setting.payloadDto.userId,
                parentId           = parentId,
                parentTitle        = parentTitle
            });

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

            return(oNegotiationplansManagementDto);
        }