Exemple #1
0
 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;
 }
Exemple #2
0
 public bool AddChallengeDay(ChallegeDay challengeDay)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var rs = entity.ChallegeDays.Add(challengeDay);
         entity.SaveChanges();
         return(rs != null);
     }
 }
Exemple #3
0
 public bool AddChallengeDay(ChallegeDay challengeDay)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         entity.Configuration.ProxyCreationEnabled = false;
         var rs = entity.ChallegeDays.Add(challengeDay);
         entity.SaveChanges();
         return rs != null;
     }
 }
Exemple #4
0
 public bool UpdateChallengeDay(ChallegeDay challengeDay)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         var coreValue = entity.ChallegeDays.FirstOrDefault(c => c.Id == challengeDay.Id);
         if (coreValue != null)
         {
             coreValue.IsProcessed = challengeDay.IsProcessed;
         }
         entity.SaveChanges();
         return(true);
     }
 }
Exemple #5
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");
 }
Exemple #6
0
 public void AddChallengeDay(ChallegeDay challengeDay)
 {
     _core.AddChallengeDay(challengeDay);
 }
Exemple #7
0
 public bool UpdateChallengeDay(ChallegeDay challengeday)
 {
     return this._core.UpdateChallengeDay(challengeday);
 }
Exemple #8
0
 public bool UpdateChallengeDay(ChallegeDay challengeDay)
 {
     using (var entity = new WakeOrWasteEntities())
     {
         var coreValue = entity.ChallegeDays.FirstOrDefault(c => c.Id == challengeDay.Id);
         if (coreValue != null)
         {
             coreValue.IsProcessed = challengeDay.IsProcessed;
         }
         entity.SaveChanges();
         return true;
     }
 }