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; }
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); } }
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; } }
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); } }
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"); }
public void AddChallengeDay(ChallegeDay challengeDay) { _core.AddChallengeDay(challengeDay); }
public bool UpdateChallengeDay(ChallegeDay challengeday) { return this._core.UpdateChallengeDay(challengeday); }
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; } }