Exemplo n.º 1
0
 public JsonResult UpdatePlan(AcPlanViewModel plan)
 {
     AcPlanEntry entry = db.AcPlanEntries.FirstOrDefault(x => x.TeamId == plan.TeamId && x.Date.Id == plan.DateId);
     if (entry != null) {
         entry.Activity = plan.Activity;
         entry.Remember = plan.Remember;
     } else {
         entry = new AcPlanEntry {
             Date = db.AcDates.Find(plan.DateId),
             TeamId = plan.TeamId,
             Activity = plan.Activity,
             Remember = plan.Remember
         };
         db.AcPlanEntries.Add(entry);
     }
     db.SaveChanges();
     return Json(new { success = true });
 }
Exemplo n.º 2
0
 public JsonResult GetAcPlan([DataSourceRequest] DataSourceRequest request, int teamId)
 {
     List<AcDate> dates = db.AcDates.Where(x => x.Date >= DateTime.Today).OrderBy(x => x.Date).ToList();
     List<AcPlanViewModel> list = new List<AcPlanViewModel>();
     foreach (AcDate date in dates) {
         AcPlanViewModel vm = new AcPlanViewModel {
             TeamId = teamId,
             Date = date.Date,
             DateId = date.Id
         };
         AcPlanEntry entry = db.AcPlanEntries.FirstOrDefault(x => x.TeamId == teamId && x.Date.Date == date.Date);
         if (entry != null) {
             vm.Activity = entry.Activity;
             vm.Remember = entry.Remember;
         }
         list.Add(vm);
     }
     return Json(list.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
 }
Exemplo n.º 3
0
 private AcPlanViewModel GetNextActivity(int teamId)
 {
     AcDate date = db.AcDates.Where(x => x.Date >= DateTime.Today).OrderBy(x => x.Date).FirstOrDefault();
     if (date == null)
         return null;
     AcPlanEntry entry = db.AcPlanEntries.Where(x => x.Date.Date == date.Date && x.TeamId == teamId).FirstOrDefault();
     AcPlanViewModel m = new AcPlanViewModel { Date = date.Date };
     if (entry != null) {
         m.Activity = entry.Activity;
         m.Remember = entry.Remember;
     }
     return m;
 }