コード例 #1
0
ファイル: Activity.cs プロジェクト: phiree/GoSport
        public Activity(string strActivityType
            ,bool allowNegative
            ,string strDateTime, string strEndTime
            ,string description
            ,BaseGround ground
            ,GOMemberShip initiator
            ,string name
            ,int serviceCharge
            ,bool isServiceChargeForEach
            ,decimal totalCost
            ,out string errMsg)
            : this()
        {
            errMsg = string.Empty;
            Activity activity = new Activity();
            enumActivityType activityType;
            if (!Enum.TryParse<PB.Model.Enums.enumActivityType>(strActivityType, out activityType))
            {
                errMsg = WebResourceManager.GetString("ActivityTypeError");
                return;
            }
            DateTime beginTime;
            if(!DateTime.TryParse(strDateTime,out beginTime))
            {
                errMsg = WebResourceManager.GetString("ActivityBeginTimeFormatError");
                return;
            }
             DateTime endTime;
            if(!DateTime.TryParse(strEndTime,out endTime))
            {
                errMsg = WebResourceManager.GetString("ActivityEndTimeFormatError");
                return;
            }
            if (string.IsNullOrEmpty(name))
            {
                errMsg = WebResourceManager.GetString("活动名称不能为空");
                return;
            }

            activity.AllowNegative = allowNegative;
            activity.BeginTime = beginTime;
            activity.EndTime = endTime;
            activity.Description = description;
            activity.Ground = ground;
            activity.Initiator = initiator;
            activity.Name = name;
            activity.ServiceCharge = serviceCharge;
            activity.IsServiceChargeForEach = isServiceChargeForEach;
            activity.TotalCost = totalCost;
        }
コード例 #2
0
ファイル: Activity.cs プロジェクト: phiree/GoSport
        public virtual bool AddMember(GOMemberShip member,out string errMsg)
        {
            decimal balance = member.PrivateBanlance - CalculateCostForEachMember();
            if (!AllowNegative && balance < 0)
            {
                errMsg = "活動要求參與用戶有足夠餘額";
            }

            bool result = true;
            errMsg = string.Empty;
            if (ActivityState != Enums.enumActivityState.Published)
            {
                errMsg = "活動處於非活動狀態,不能加入";
                return false;
            }
            ActivityMember am = new ActivityMember();
            am.Activity = this;
            am.JoinTime = DateTime.Now;
            am.Member = member;
            Participants.Add(am);
            return result;
        }