コード例 #1
0
        public JsonResult GetPromotionByCustomers([DataSourceRequest] DataSourceRequest dataSourceRequest, int?customerID, int?applyToSalesVersusReturns, int?filterApplyToTradeDiscount, bool?forDropDownList)
        {
            if (customerID == null)
            {
                return(Json(null));
            }

            IList <Promotion> result = promotionAPIRepository.GetPromotionByCustomers(customerID, applyToSalesVersusReturns, filterApplyToTradeDiscount); //filterApplyToTradeDiscount == 0 || 1 || -1 => WHERE: -1 MEAN: SELECT ALL

            if (forDropDownList != null && (bool)forDropDownList)
            {
                if (result.Count() > 0 && result.FirstOrDefault(w => w.ApplyToAllCommodities) == null)
                {
                    result.Insert(0, new Promotion()
                    {
                        Specs = "KHÔNG ÁP DỤNG CK TỔNG  [CK 1 DÒNG]"
                    });
                }

                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(result.ToDataSourceResult(dataSourceRequest), JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public virtual ActionResult Promotion(int id)
        {
            CustomerViewModel customerViewModel = this.GetViewModel(id, GlobalEnums.AccessLevel.Readable);

            if (customerViewModel == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ViewBag.Promotions = promotionAPIRepository.GetPromotionByCustomers(null, (int)GlobalEnums.ApplyToSalesVersusReturns.ApplyToAll, null).Select(pt => new SelectListItem {
                Text = pt.Specs + " => " + pt.EndDate.ToString(), Value = pt.PromotionID.ToString()
            }).ToList();

            return(View(customerViewModel));
        }