Exemplo n.º 1
0
        public static SUserSellerRptResponse GetSellerReportBySuperUser(SUserSellerRptRequest request)
        {
            SUserSellerRptResponse response = new SUserSellerRptResponse();

            try
            {
                var productIdList = request.products.Select(x => x.product_id).ToList();
                if (!SuperUserServices.CheckSuperUser(request.user_id, request.auth_token, response))
                {
                    response.message = MessagesSource.GetMessage("invalid.super.user");
                    return(response);
                }
                response.sales_details = new List <SUserSellerRptDto>();
                using (OrderDao dao = new OrderDao())
                {
                    int periodRange = Common.GetAppSetting <int>(APPSETTING_REPORTPERIOD_RANGE, 6);

                    if (productIdList != null && productIdList.Count > 0)
                    {
                        string productIds = string.Join(",", productIdList.Select(n => n.ToString()).ToArray());

                        var sellerRpt = dao.GetSellerReportBySUser(request.user_id, request.total_type, request.periodical_data, periodRange, request.number_of_products, productIds, request.agency_id);
                        if (sellerRpt != null && sellerRpt.Count > 0)
                        {
                            response.sales_details = sellerRpt.Select(r => new SUserSellerRptDto
                            {
                                key   = r.Period,
                                value = r.Value.ToDecimal()
                            }).ToList();
                        }
                    }
                    response.code         = 0;
                    response.has_resource = 1;
                    response.message      = MessagesSource.GetMessage("suser.sales.report");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }
        public NegotiatedContentResult <SUserSellerRptResponse> PostGetSellerReportBySuperUser([FromBody] SUserSellerRptRequest request)
        {
            SUserSellerRptResponse resp = ReportsServices.GetSellerReportBySuperUser(request);

            return(Content(HttpStatusCode.OK, resp));
        }