Exemplo n.º 1
0
        public async Task <GetNegotiationsManagementDto> getNegotiationsManagement(int pageNo, string filter)
        {
            GetNegotiationsManagementDto oNegotiationsManagementDto = await
                                                                      _NegotiationService.getNegotiationsManagement(new GridInitialDto
            {
                recordCountPerPage = Setting.RECORD_COUNT_PAGE,
                pageNo             = pageNo,
                filter             = filter,
                userId             = Setting.payloadDto.userId
            });

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

            return(oNegotiationsManagementDto);
        }
Exemplo n.º 2
0
        public async Task <GetNegotiationsManagementDto> getNegotiationsManagement(GridInitialDto gridInitialDto)
        {
            if (gridInitialDto.pageNo < 1)
            {
                gridInitialDto.pageNo = 1;
            }


            var oNegotiationsManagementDto = new GetNegotiationsManagementDto();


            IQueryable <Negotiation> oNegotiations = _Negotiations.Include(r => r.placeofDeliveryLocation)
                                                     .Include(r => r.placeofReceiptLocation)
                                                     .Include(i => i.currency).Include(i => i.contractor);

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

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

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

                var intFrom = (gridInitialDto.pageNo - 1) * gridInitialDto.recordCountPerPage;
                oNegotiationsManagementDto.getOutNegotiationsDto = Mapper.Map <IEnumerable <Negotiation>, List <GetNegotiationsDto> >(await oNegotiations.GetPageRecords(gridInitialDto.pageNo, gridInitialDto.recordCountPerPage).ToListAsync());

                oNegotiationsManagementDto.currentPage      = gridInitialDto.pageNo;
                oNegotiationsManagementDto.totalRecordCount = totalRecordCount;
            }

            return(oNegotiationsManagementDto);
        }