Beispiel #1
0
        public async Task <VMTaskIndex> IndexAsync(string userId, string taskGroupId = null)
        {
            var data = new VMTaskIndex();

            var tasks = VMTask.Fetch(DBContext.TaskItems);

            if (taskGroupId != null)
            {
                tasks = tasks.Where(m => m.Group.Id == taskGroupId);
                var group = await DBContext.TaskGroups.FindAsync(taskGroupId);

                data.GroupId    = group.Id;
                data.GroupTitle = group.Title;
            }
            else
            {
                data.GroupTitle = "All";
            }

            tasks = tasks
                    .Where(t => t.AssignedUserId == null || t.AssignedUserId == userId)
                    .Where(t => t.CompletionDate == null);

            tasks = tasks.OrderByDescending(t => t.Priority);

            data.Tasks = tasks.Select(VMTask.Read(DBContext)).ToList();

            return(data);
        }
Beispiel #2
0
        public ActionResult index(int?pageId)
        {
            VMTaskIndex mod = new VMTaskIndex();

            using (MDB db = new MDB())
            {
                mod.CurrentPage = pageId.GetValueOrDefault();
                mod.Tasks       = db.Find <DbTask>(x => true).OrderByDescending(x => x.Increase).Skip(mod.CurrentPage * mod.PageSize).Take(mod.PageSize).ToList();
                mod.TotalCount  = db.Find <DbTask>(x => true).Count;
            }

            return(View(mod));
        }