Exemple #1
0
        public JsonResult Add(Mall.Entities.MemberGradeInfo model)
        {
            if (!(1 <= model.Discount && model.Discount <= 10))
            {
                return(Json(new Result()
                {
                    success = false, msg = "可享受折扣率允许范围1-10折!"
                }));
            }
            string erroMsg;

            if (!CheckMemberGrade(model, out erroMsg))
            {
                return(Json(new Result()
                {
                    success = false, msg = erroMsg
                }));
            }

            _iMemberGradeService.AddMemberGrade(model);
            return(Json(new Result()
            {
                success = true, msg = "添加成功!"
            }));
        }
Exemple #2
0
        private bool CheckMemberGrade(Mall.Entities.MemberGradeInfo model, out string erroMsg)
        {
            bool flag = true;

            erroMsg = "";
            if (string.IsNullOrWhiteSpace(model.GradeName))
            {
                erroMsg = "会员等级名称不能为空";
                flag    = false;
            }
            if (model.Integral < 0)
            {
                erroMsg = "积分不能小于0";
                flag    = false;
            }
            return(flag);
        }