public ActionResult GetLotteryWinnerList() { string strPeriodId = Request.QueryString["periodId"]; if (String.IsNullOrEmpty(strPeriodId)) { return(RespondResult(false, "参数无效。")); } Guid periodId = Guid.Parse(strPeriodId); Campaign_LotteryPeriodEntity period = _campaignManager.Lottery.GetLotteryPeriod(periodId); GetLotteryWinnerListResult result = _campaignManager.Lottery.GetLotteryWinnerList(periodId); bool isWinner = false; if (MemberContext != null) { isWinner = _campaignManager.Lottery.IsLotteryWinner(periodId, MemberContext.Member.Id); } return(RespondDataResult(new { Period = period, WinnerList = result.ItemList, IsWinner = isWinner })); }
public ActionResult GetLotteryPeriod() { string id = Request.QueryString["id"]; if (String.IsNullOrEmpty(id)) { return(RespondResult(false, "参数无效。")); } Campaign_LotteryPeriodEntity period = _campaignManager.Lottery.GetLotteryPeriod(Guid.Parse(id)); Campaign_LotterySignLogEntity log = null; if (MemberContext != null) { log = _campaignManager.Lottery.GetLotteryPeriodLog( period.CampaignId, period.Id, MemberContext.Member.Id); } return(RespondDataResult(new { Period = period, Log = log })); }
public void CreateLotteryPeriod(Campaign_LotteryPeriodEntity lotteryPeriod) { if (lotteryPeriod == null) { Debug.Assert(false, "lotteryPeriod == null"); return; } _campaignManager.DataBase.Insert(lotteryPeriod); }
public Campaign_LotteryPeriodEntity GetLotteryPeriod(Guid id) { Campaign_LotteryPeriodEntity campaign = new Campaign_LotteryPeriodEntity(); campaign.Id = id; if (_campaignManager.DataBase.Fill <Campaign_LotteryPeriodEntity>(campaign)) { return(campaign); } else { return(null); } }
public NormalResult UpdateLotteryPeriod(Campaign_LotteryPeriodEntity lotteryPeriod) { if (lotteryPeriod == null) { Debug.Assert(false, "lotteryPeriod == null"); return(new NormalResult("参数错误。")); } //所属活动如果已结束则不允许修改 EnumCampaignStatus?campaignStatus = _campaignManager.GetStatus(lotteryPeriod.CampaignId); if (campaignStatus == null) { return(new NormalResult("活动不存在。")); } if (campaignStatus.Value == EnumCampaignStatus.End) { return(new NormalResult("已结束活动的周期不允许修改。")); } Campaign_LotteryPeriodEntity current = GetLotteryPeriod(lotteryPeriod.Id); if (current == null) { return(new NormalResult("要修改的周期不存在。")); } if (current.Drawn) { return(new NormalResult("已完成抽奖的周期不允许修改。")); } //对于正在进行中的活动,已经结束或抽过奖的周期不允许修改 if (campaignStatus.Value == EnumCampaignStatus.Ongoing) { if (current.EndTime <= DateTime.Now || current.Drawn) { return(new NormalResult("已结束的周期不可修改。")); } } _campaignManager.DataBase.Update(lotteryPeriod); return(new NormalResult()); }