public async Task <HttpResponseMessage> GetDataList(int goodsCategoryTypeId, bool?isActive = null, int?iGoalTypeId = null)
        {
            GoalGoodsCategoryTypeEnum catTypeId = default(GoalGoodsCategoryTypeEnum);
            GoalTypeEnum goalTypeId             = default(GoalTypeEnum);

            if (goodsCategoryTypeId != 0)
            {
                catTypeId = Utilities.ToEnum <GoalGoodsCategoryTypeEnum>(goodsCategoryTypeId).Value;
            }
            if (iGoalTypeId.HasValue)
            {
                goalTypeId = Utilities.ToEnum <GoalTypeEnum>(iGoalTypeId).Value;
            }
            IBusinessResultValue <List <GoalGoodsCategory> > entities = await businessService.LoadVisibleGoalGoodsCategoryListAsync(
                where : x => (x.GoalGoodsCategoryTypeId == catTypeId || goodsCategoryTypeId == 0) &&
                (x.GoalTypeId == goalTypeId || iGoalTypeId.HasValue == false) &&
                (x.IsActive == isActive || isActive.HasValue == false));

            if (entities.ReturnStatus == false)
            {
                CreateErrorResponse(entities);
            }
            var mapper     = GetMapper();
            var dataSource = mapper.Map <List <GoalGoodsCategoryViewModel> >(entities.ResultValue);

            return(CreateSuccessedListResponse(dataSource));
        }
        public async Task <HttpResponseMessage> GetBranchPromotionDetail(string startDate, string endDate)
        {
            DateTime?startDateTime = Utilities.ToDateTime(startDate);
            DateTime?endDateTime   = Utilities.ToDateTime(endDate);

            GoalGoodsCategoryTypeEnum[] goalGoodsCategoryTypeIds = new GoalGoodsCategoryTypeEnum[] { GoalGoodsCategoryTypeEnum.Group
                                                                                                     , GoalGoodsCategoryTypeEnum.Single };
            var entity = await promotionBS.LoadReportBranchPromotionDetail(startDateTime.Value, endDateTime.Value, goalGoodsCategoryTypeIds);

            if (entity.ReturnStatus == false)
            {
                return(CreateErrorResponse(entity));
            }

            var dataResult = entity.ResultValue.GroupBy(x => x.BranchId)
                             .Select(x => new ReportBranchPromotionDetailViewModel
            {
                BranchId   = x.Key,
                BranchName = x.FirstOrDefault(y => y.BranchId == x.Key).BranchName,
                ManagerFulfillmentPercent = x.FirstOrDefault(y => y.BranchId == x.Key).ManagerFulfillmentPercent,
                SellerFulfillmentPercent  = x.FirstOrDefault(y => y.BranchId == x.Key).SellerFulfillmentPercent,
                TotalFinalPromotion       = x.FirstOrDefault(y => y.BranchId == x.Key).TotalFinalPromotion,
                TotalPromotionWithOutFulfillmentPercent = x.FirstOrDefault(y => y.BranchId == x.Key).TotalPromotionWithOutFulfillmentPercent,
                GoalPromotions = x.Select(y => new GoalPromotion
                {
                    FinalPromotion        = y.FinalPromotion,
                    GoalGoodsCategoryName = y.GoalGoodsCategoryName,
                    PromotionWithOutFulfillmentPercent = y.PromotionWithOutFulfillmentPercent
                }).ToList()
            }).ToList();

            return(CreateSuccessedListResponse(dataResult));
        }
Exemplo n.º 3
0
        private bool CheckGoal(Promotion entity, GoalGoodsCategoryTypeEnum goalGoodsTypeId)
        {
            var result = unitOfWork.GoalDataService
                         .GetQuery()
                         .Any(x => x.GoalGoodsCategoryTypeId == goalGoodsTypeId && x.Month == entity.Month && x.Year == entity.Year &&
                              x.IsUsed == false && x.Deleted == false);

            return(result);
        }
        public async Task <HttpResponseMessage> ExportExcelBranchPromotionDetail(string startDate, string endDate)
        {
            DateTime?startDateTime = Utilities.ToDateTime(startDate);
            DateTime?endDateTime   = Utilities.ToDateTime(endDate);

            GoalGoodsCategoryTypeEnum[] goalGoodsCategoryTypeIds = new GoalGoodsCategoryTypeEnum[] { GoalGoodsCategoryTypeEnum.Group
                                                                                                     , GoalGoodsCategoryTypeEnum.Single };

            var entity = await promotionBS.LoadReportBranchPromotionDetail(startDateTime.Value, endDateTime.Value, goalGoodsCategoryTypeIds);

            if (entity.ReturnStatus == false)
            {
                return(CreateErrorResponse(entity));
            }

            var dataResult = entity.ResultValue.GroupBy(x => x.BranchId)
                             .Select(x => new ReportBranchPromotionDetailViewModel
            {
                BranchId   = x.Key,
                BranchName = x.FirstOrDefault(y => y.BranchId == x.Key).BranchName,
                ManagerFulfillmentPercent = x.FirstOrDefault(y => y.BranchId == x.Key).ManagerFulfillmentPercent,
                SellerFulfillmentPercent  = x.FirstOrDefault(y => y.BranchId == x.Key).SellerFulfillmentPercent,
                TotalFinalPromotion       = x.FirstOrDefault(y => y.BranchId == x.Key).TotalFinalPromotion,
                TotalPromotionWithOutFulfillmentPercent = x.FirstOrDefault(y => y.BranchId == x.Key).TotalPromotionWithOutFulfillmentPercent,
                GoalPromotions = x.Select(y => new GoalPromotion
                {
                    FinalPromotion        = y.FinalPromotion,
                    GoalGoodsCategoryName = y.GoalGoodsCategoryName,
                    PromotionWithOutFulfillmentPercent = y.PromotionWithOutFulfillmentPercent
                }).ToList()
            }).ToList();

            string downloadUrl   = $"/excel/branch_sales_overview{DateTime.Now.Ticks}.xlsx";
            string caption       = $" گزارش پورسانت مراکز از فروش {startDate} - {endDate} ";
            var    excelTemplate = HostingEnvironment.MapPath("/Views/Promotion/rptbranchsalesoverview/excelTemplate.html");

            using (var package = new ExcelPackage())
            {
                ExportToExcel.CreateExcelFile <ReportBranchPromotionDetailViewModel>(dataResult
                                                                                     , outputFileName: downloadUrl
                                                                                     , excelTemplatePath: excelTemplate
                                                                                     , caption: caption
                                                                                     , package: package
                                                                                     , getLoopObjects: (ReportBranchPromotionDetailViewModel record) => record.GoalPromotions
                                                                                     );
            }

            return(Request.CreateResponse(HttpStatusCode.OK, downloadUrl));
        }
        public async Task <HttpResponseMessage> GetListforReport(int goodsCategoryTypeId, int iGoalTypeId
                                                                 , string startDate
                                                                 , string endDate)
        {
            GoalGoodsCategoryTypeEnum catTypeId = Utilities.ToEnum <GoalGoodsCategoryTypeEnum>(goodsCategoryTypeId).Value;
            GoalTypeEnum goalTypeId             = Utilities.ToEnum <GoalTypeEnum>(iGoalTypeId).Value;

            IBusinessResultValue <List <GoalGoodsCategory> > entities = await businessService.LoadGoalGoodsCategoryForReportAsync(catTypeId
                                                                                                                                  , goalTypeId
                                                                                                                                  , Utilities.ToDateTime(startDate).Value
                                                                                                                                  , Utilities.ToDateTime(endDate).Value
                                                                                                                                  );

            if (entities.ReturnStatus == false)
            {
                CreateErrorResponse(entities);
            }
            var mapper     = GetMapper();
            var dataSource = mapper.Map <List <GoalGoodsCategoryViewModel> >(entities.ResultValue);

            return(CreateSuccessedListResponse(dataSource));
        }
Exemplo n.º 6
0
        public async Task <IBusinessResultValue <List <GoalGoodsCategory> > > LoadGoalGoodsCategoryForReportAsync(GoalGoodsCategoryTypeEnum goodsCategoryTypeId, GoalTypeEnum goalTypeId, DateTime startDate, DateTime endDate)
        {
            var result = new BusinessResultValue <List <GoalGoodsCategory> >();

            try
            {
                result.ResultValue = await(from goal in unitOfWork.GoalDataService.GetQuery()
                                           join ggc in unitOfWork.GoalGoodsCategoryDataService.GetQuery()
                                           on goal.GoalGoodsCategoryId equals ggc.Id
                                           where goal.StartDate >= startDate && goal.EndDate <= endDate &&
                                           goal.GoalGoodsCategoryTypeId == goodsCategoryTypeId &&
                                           goal.GoalTypeId == goalTypeId
                                           select ggc).ToListAsync();
            }
            catch (Exception ex)
            {
                CatchException(ex, result, "");
            }
            return(result);
        }