コード例 #1
0
        public virtual void UpdateCredit(long id)
        {
            SiteRank rank   = roleService.GetRankById(id);
            int      credit = ctx.PostInt("Credit");

            SiteRank preRank = roleService.GetPreRank(rank);

            if (preRank == null)
            {
                echoToParentPart(lang("exCreditFirst"));
                return;
            }

            if (credit <= 0)
            {
                errors.Add(lang("exCreditGreat0"));
                run(CreditEdit, id);
                return;
            }

            int      nextCredit = int.MaxValue;
            SiteRank nextRank   = roleService.GetNextRank(rank);

            if (nextRank != null)
            {
                nextCredit = nextRank.Credit;
            }

            if (!(credit > preRank.Credit && credit < nextCredit))
            {
                String msg = lang("exCreditBetween");
                errors.Add(string.Format(msg, preRank.Credit, nextCredit));
                run(CreditEdit, id);
                return;
            }

            rank.Credit = credit;
            roleService.UpdateRank(rank);
            log(SiteLogString.UpdateCredit(), rank);

            echoToParentPart(lang("opok"));
        }