Example #1
0
File: WoWBiz.cs Project: duylt/wow
        public bool ChallengeWake(Challenge challenge, bool processed = false)
        {
            challenge = this.GetChallenge(challenge.Id);
            var todayChallenge = challenge.ChallegeDays.Where(cld => cld.Date.Date.Equals(DateTime.Now.Date)).FirstOrDefault();

            if (todayChallenge == null)
            {
                ChallegeDay day = new ChallegeDay
                {
                    ChallengeId = challenge.Id,
                    Date        = DateTime.Now,
                    Succeed     = true,
                    UserId      = challenge.UserId,
                    IsProcessed = processed
                };
                this._core.AddChallengeDay(day);
                challenge.ChallegeDays.Add(day);
            }
            //Process to post facebook challenge
            if (!processed)
            {
                TempBiz tempBiz = new TempBiz();
                tempBiz.ChallengeProcess(challenge);
            }
            return(true);
        }
Example #2
0
        public ActionResult CompleteChallenge()
        {
            var challenge = GetCurrentChallenge(true);

            if (challenge == null)
            {
                return(RedirectToActionPermanent("CreateChallenge"));
            }
            if (IsLastDate(challenge))
            {
                var todayChallenge = challenge.ChallegeDays.Where(cd => cd.Date.Date.Equals(DateTime.Now.Date)).FirstOrDefault();
                if (IsFirstWakeWaste && todayChallenge == null)
                {
                    var settingTime = DateTime.Now;
                    settingTime = settingTime.AddHours(challenge.WakeUpTime.Value.Hours);
                    settingTime = settingTime.AddMinutes(challenge.WakeUpTime.Value.Minutes);
                    ChallegeDay lastDate = new ChallegeDay()
                    {
                        ChallengeId = challenge.Id,
                        Date        = DateTime.Now,
                        IsProcessed = true,
                        UserId      = CurrentUser.Id,
                    };
                    if ((settingTime.AddHours(-1) <= DateTime.Now) && (settingTime.AddMinutes(10) >= DateTime.Now))
                    {
                        lastDate.Succeed = true;
                    }
                    else
                    {
                        lastDate.Succeed = false;
                    }
                    biz.AddChallengeDay(lastDate);
                    IsFirstWakeWaste = false;
                }
                Session["FromComleted"] = true;
                return(RedirectToActionPermanent("Statistics"));
            }
            return(RedirectToActionPermanent("Index"));
        }
Example #3
0
File: WoWBiz.cs Project: duylt/wow
 public void AddChallengeDay(ChallegeDay challengeDay)
 {
     _core.AddChallengeDay(challengeDay);
 }
Example #4
0
File: WoWBiz.cs Project: duylt/wow
 public bool UpdateChallengeDay(ChallegeDay challengeday)
 {
     return(this._core.UpdateChallengeDay(challengeday));
 }