public Result Add(ViewOrder order)
        {
            Result result = CanApply(order.ClassId, order.Number);

            if (result.Code == 0)
            {
                ClassServiceClient cc = new ClassServiceClient();
                ViewClass          vc = cc.Get(order.ClassId);
                order.Amount = (double)vc.Price * order.Number;
                return(Impl.Add(order));
            }
            else
            {
                return(result);
            }
        }
        public Result CanApply(int classID, int count)
        {
            ClassServiceClient cc = new ClassServiceClient();
            ViewClass          vc = cc.Get(classID);

            if (vc.ClassStatus == 2)
            {
                int hasAppliedNumber = AppliedNumber(classID, ORDER_TIME_OUT);
                if (hasAppliedNumber < vc.Max)
                {
                    if (hasAppliedNumber + count <= vc.Max)
                    {
                        if (DateTime.Parse(vc.Start) > DateTime.Now)
                        {
                            return(new Result(0, "OK"));
                        }
                        else
                        {
                            return(new Result(1, "活动已经开始了"));
                        }
                    }
                    else
                    {
                        return(new Result(1, string.Format("名额不足,还剩 {0} 个名额", (vc.Max - hasAppliedNumber - count))));
                    }
                }
                else
                {
                    return(new Result(1, "报名已满"));
                }
            }
            else
            {
                return(new Result(1, "活动已不能报名!"));
            }
        }