Exemple #1
0
        public InternalRequisitionFormModel SearchInternalRequisitionFormModels(
            [FromUri] OrderAdminSearchCriteria searchCriteria, [FromUri] PaginationOptions paginationOptions)
        {
            var tbl = _orderReportService.SearchInternalRequisitionForm(_workContext.User, paginationOptions,
                                                                        searchCriteria);

            var dataRows = tbl.AsEnumerable().Skip((paginationOptions.PageIndex - 1) * paginationOptions.PageSize).Take(paginationOptions.PageSize);

            int     summaryTotalAmount = 0;
            decimal summaryTotalPV     = 0;
            decimal summaryTotalPrice  = 0;

            var model = dataRows.Select(Mapper.Map <DataRow, InternalRequisitionRowModel>).ToList();

            if (model.Count > 0)
            {
                summaryTotalAmount = Convert.ToInt32(tbl.Compute("Sum(Quantity)", ""));
                summaryTotalPV     = Convert.ToDecimal(tbl.Compute("Sum(TotalPV)", ""));
                summaryTotalPrice  = Convert.ToDecimal(tbl.Compute("Sum(TotalPrice)", ""));
            }

            return(new InternalRequisitionFormModel()
            {
                Data = model,
                TotalItems = tbl.Rows.Count,
                SummaryTotalAmount = summaryTotalAmount,
                SummaryTotalPV = summaryTotalPV,
                SummaryTotalPrice = summaryTotalPrice
            });
        }