Beispiel #1
0
        public SummaryDiscountProductModel SearchSummaryDiscountProductModels(
            [FromUri] OrderAdminSearchCriteria searchCriteria, [FromUri] PaginationOptions paginationOptions)
        {
            var tbl = _orderReportService.SearchSummaryDiscountProduct(_workContext.User, paginationOptions,
                                                                       searchCriteria);

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

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


            int     summaryTotalAmount          = 0;
            decimal summaryTotalDiscountedPrice = 0;
            decimal summaryTotalPrice           = 0;

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


            return(new SummaryDiscountProductModel()
            {
                Data = model,
                SummaryTotalPrice = summaryTotalPrice,
                SummaryTotalAmount = summaryTotalAmount,
                SummaryTotalDiscountedPrice = summaryTotalDiscountedPrice,
                TotalItems = tbl.Rows.Count
            });
        }
        private SummaryDiscountProductModel GetDiscountOrders(OrderAdminSearchCriteria searchCriteria,
                                                              PaginationOptions paginationOptions)
        {
            searchCriteria.OrderBatchStatus = OrderBatchStatus.Approved;
            var tbl = _orderReportService.SearchSummaryDiscountProduct(_workContext.User, paginationOptions,
                                                                       searchCriteria);

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

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


            int     summaryTotalAmount          = 0;
            decimal summaryTotalDiscountedPrice = 0;
            decimal summaryTotalPrice           = 0;

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


            var summaryDiscountProductModel = new SummaryDiscountProductModel()
            {
                Data = model,
                SummaryTotalPrice           = summaryTotalPrice,
                SummaryTotalAmount          = summaryTotalAmount,
                SummaryTotalDiscountedPrice = summaryTotalDiscountedPrice,
                TotalItems = tbl.Rows.Count
            };

            return(summaryDiscountProductModel);
        }