Example #1
0
        public ActionResult Paging(int num)
        {
            var list       = PromoManagement.GetAllPromotionList();
            var promotions = ApplyPaging(list, num);

            return(Json(promotions, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public ActionResult PromotionSection()
        {
            var serializer    = new JavaScriptSerializer();
            var allPromotions = PromoManagement.GetAllPromotionList();
            var promotions    = ApplyPaging(allPromotions, 1);

            ViewBag.PromotionDetail    = serializer.Serialize(new EditPromotionDTO());
            ViewBag.Promotions         = serializer.Serialize(promotions);
            ViewBag.TotalPromotionPage = (int)Math.Ceiling(((double)allPromotions.Count() / (double)pageSize));
            return(View());
        }
Example #3
0
        public ActionResult GetPromotionDetail(string promotionCode)
        {
            var promotion       = PromoManagement.GetAllPromotionList().Single(x => x.CodeId == promotionCode);
            var promotionDetail = new EditPromotionDTO
            {
                CodeId     = promotion.CodeId,
                Price      = promotion.Price,
                Rate       = promotion.Rate,
                IsCreating = false,
                Hidden     = promotion.Hidden
            };

            return(Json(new { promotionDetail }, JsonRequestBehavior.AllowGet));
        }
Example #4
0
        public ActionResult CreateUpdatePromotion(EditPromotionDTO dto)
        {
            if (dto == null)
            {
                throw new NullReferenceException("DTO cannot be null");
            }
            var validationIds     = new List <string>();
            var validationMessage = Validate(dto, out validationIds);

            if (!validationMessage.Any())
            {
                if (dto.IsCreating)
                {
                    PromoManagement.AddPromotion(dto);
                }
                else
                {
                    PromoManagement.UpdatePromotion(dto);
                }

                var promotions = PromoManagement.GetAllPromotionList();

                var totalProductPage = (int)Math.Ceiling(((double)promotions.Count() / (double)pageSize));
                return(Json(new
                {
                    promotions = ApplyPaging(promotions, 1),
                    passed = !validationMessage.Any(),
                    validationIds,
                    validationMessage = string.Join("</br>", validationMessage),
                    totalProductPage
                }));
            }

            return(Json(new
            {
                passed = !validationMessage.Any(),
                validationIds,
                validationMessage = string.Join("</br>", validationMessage)
            }));
        }
Example #5
0
        /// <summary>
        /// Get Promotion Info and return in Json String
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult GetPromotionInfo(string id)
        {
            var promotion = PromoManagement.GetActivePromotion(id);

            return(Json(new { isValid = promotion != null, promotion }));
        }