コード例 #1
0
        internal static void Schedule()
        {
            GetItDoneContext    db        = new GetItDoneContext("GetItDone");
            List <TaskSchedule> schedules = (from s in db.Schedules.Include("Task") select s).ToList <TaskSchedule>();

            foreach (TaskSchedule schedule in schedules)
            {
                schedule.Tasks.Sort(new Comparison <Task>((t1, t2) => { return((t1.Created - t2.Created).Hours); }));
                Task latestChildTask = schedule.Tasks[0];
                if (latestChildTask == null || (DateTime.Now - latestChildTask.Created).TotalDays > schedule.Schedule)
                {
                    db.Entry(latestChildTask).State = System.Data.Entity.EntityState.Detached;
                    latestChildTask.Created         = DateTime.Now;
                    db.Tasks.Add(latestChildTask);
                    db.SaveChanges();
                }
            }
        }
コード例 #2
0
        public List <Board> Boards()
        {
            User user = CookieHelper.LoggedInUser(Request, db);

            if (user != null)
            {
                db.Entry(user).Collection(u => u.Boards).Load();
                return(user.Boards);
            }
            return(null);
        }