コード例 #1
0
        public void DbItemCounts()
        {
            // Arrange

            int dbProjectCount = db.GetMyProjects(user).Count();
            int dbTaskCount    = db.GetMyTasks(user).Count();
            int dbActionCount  = db.GetMyActions(user).Count();

            //////////////////////////////////////////

            // Act

            //create project
            project = CreateProject();

            //create task
            task = CreateTask(project.ID);

            //create action
            action = CreateAction(task.ID);

            //////////////////////////////////////////

            // Assert

            Assert.AreEqual <int>(db.GetMyProjects(user).Count(), dbProjectCount + 1);
            Assert.AreEqual <int>(db.GetMyTasks(user).Count(), dbTaskCount + 1);
            Assert.AreEqual <int>(db.GetMyActions(user).Count(), dbActionCount + 1);
        }
コード例 #2
0
        public ActionResult EditOld(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var actionToUpdate = db.GetActionById(User, id.Value);

            if (actionToUpdate == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TaskID = new SelectList(db.GetMyTasks(User), "ID", "Code", actionToUpdate.TaskID);
            return(View(actionToUpdate));
        }
コード例 #3
0
        private SearchResults SearchTasks(string term = "", SearchResults currentResults = null, Status?status = null)
        {
            if (currentResults == null)
            {
                currentResults = new SearchResults();
            }
            currentResults.SearchTerm = term;

            currentResults.TaskResults = db.GetMyTasks(User)
                                         .Where(t =>
                                                t.Code.ToLower().Contains(currentResults.SearchTerm) ||
                                                t.Name.ToLower().Contains(currentResults.SearchTerm) ||
                                                t.Description.ToLower().Contains(currentResults.SearchTerm))
                                         .Where(t =>
                                                !status.HasValue || t.Status == status.Value)
                                         .ToList();

            return(currentResults);
        }
コード例 #4
0
        // GET: /Task/
        public ViewResult Index(string sortOrder, string currentFilter, string searchString, int?page)
        {
            ViewBag.ProjectSortParm      = (sortOrder == "proj") ? "proj_desc" : "proj";
            ViewBag.CodeSortParm         = (sortOrder == "code") ? "code_desc" : "code";
            ViewBag.NameSortParm         = (sortOrder == "name") ? "name_desc" : "name";
            ViewBag.EndDateSortParm      = (sortOrder == "date") ? "date_desc" : "date";
            ViewBag.EstimateSortParm     = (sortOrder == "esti") ? "esti_desc" : "esti";
            ViewBag.StatusSortParm       = (sortOrder == "stat") ? "stat_desc" : "stat";
            ViewBag.PrioritySortParm     = (sortOrder == "prio") ? "prio_desc" : "prio";
            ViewBag.LastPomodoroSortParm = (sortOrder == "last") ? "last_desc" : "last";
            ViewBag.PomodorosSortParm    = (sortOrder == "pomo") ? "pomo_desc" : "pomo";
            ViewBag.ProgressSortParm     = (sortOrder == "prog") ? "prog_desc" : "prog";
            ViewBag.EffortSortParm       = (sortOrder == "effo") ? "effo_desc" : "effo";
            ViewBag.ActionsSortParm      = (sortOrder == "acti") ? "acti_desc" : "acti";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            //var tasks = db.Tasks.Include(t => t.Project);
            var tasks = db.GetMyTasks(User);

            //stores the current filter info for the pagination control
            RouteValueDictionary dict = new RouteValueDictionary();

            //initilised with the current sort order
            dict["CurrentSort"] = sortOrder;

            //status filter
            const string STATUS_PREFIX = "status-";

            string[] statusFilter = GetArrayParamsFromRequest(Request.QueryString, STATUS_PREFIX);
            if (statusFilter.Length > 0)
            {
                tasks = tasks.ToList().AsQueryable()
                        .Where(t => statusFilter
                               .Any(sf => sf.ToLower() == t.CalculatedStatus.ToString().ToLower())
                               );
                dict.AddFilterArrayToRouteValueDictionary(statusFilter, STATUS_PREFIX);
            }

            //tag filter
            const string TAG_PREFIX = "tag-";

            string[] tagFilter = GetArrayParamsFromRequest(Request.QueryString, TAG_PREFIX);
            if (tagFilter.Length > 0)
            {
                //OR Tag Filter
                tasks = tasks.ToList().AsQueryable()
                        .Where(t => tagFilter
                               .Any(tf => t.OwnAndInheritedTags //all tags in the filter
                                    .Select(tc => tc.Code)      //(only tag code list)
                                    .Contains(tf))              //contained in the item tags
                               );
                //AND Tag Filter
                //tasks = tasks.ToList().AsQueryable()
                //    .Where(t => tagFilter
                //        .All(tf => t.OwnAndInheritedTags    //all tags in the filter
                //            .Select(tc => tc.Code)          //(only tag code list)
                //                .Contains(tf))              //contained in the item tags
                //);
                dict.AddFilterArrayToRouteValueDictionary(tagFilter, TAG_PREFIX);
            }

            //priority filter
            const string PRIORITY_PREFIX = "priority-";

            string[] priorityFilter = GetArrayParamsFromRequest(Request.QueryString, PRIORITY_PREFIX);
            if (priorityFilter.Length > 0)
            {
                tasks = tasks.ToList().AsQueryable()
                        .Where(t => priorityFilter
                               .Any(pf => pf.ToLower() == t.Priority.ToString().ToLower())
                               );
                dict.AddFilterArrayToRouteValueDictionary(priorityFilter, PRIORITY_PREFIX);
            }

            ViewBag.IsFiltered = string.IsNullOrEmpty(Request.QueryString["filtering"]) == false ||
                                 (statusFilter.Length > 0) || (priorityFilter.Length > 0) || (tagFilter.Length > 0);
            ViewBag.RouteFiltersForPagination = dict;

            ViewBag.StatusFilter   = statusFilter;
            ViewBag.PriorityFilter = priorityFilter;
            ViewBag.TagFilter      = tagFilter;
            //ViewBag.CurrentFilter = searchString;

            ViewBag.AllTags = db.GetMyTags(User).ToArray();

            orderBySortParam(ref tasks, sortOrder);

            int pageSize   = 20;
            int pageNumber = (page ?? 1);

            return(View(tasks.ToPagedList(pageNumber, pageSize)));
        }
コード例 #5
0
        // GET: /Dashboard
        public ViewResult Dashboard()
        {
            DashboardViewModel dashboard = new DashboardViewModel();

            //active projects
            dashboard.ActiveProjects = db.GetMyProjects(User).ToList().Where(p => p.IsActive);

            //active tasks
            dashboard.ActiveTasks = db.GetMyTasks(User).ToList().Where(t => t.IsActive);

            //active actions
            dashboard.ActiveActions = db.GetMyActions(User).ToList().Where(a => a.IsActive);

            //completed pomodoros
            dashboard.CompletedPomodoros = db.GetMyPomodoros(User).ToList().Where(p => p.Status == PomodoroStatus.Completed);

            //last active actions
            dashboard.LastActiveActions = new PomodoroContainerDateViewModel
            {
                HeaderTitle    = "Last Active Actions",
                TableId        = "last-active-actions",
                IconCssClass   = "fa-play",
                ReportTypeDate = ReportTypeDate.LastPomodoro,
                RowsPerPage    = 5,
                Type           = PomodoroContainerType.Action,
                Items          = db.GetMyPomodoros(User)
                                 .Where(pm => pm.Status == PomodoroStatus.Completed && pm.Start.HasValue)
                                 .Select(pm => pm.Action)
                                 .Distinct().ToList()
                                 .OrderByDescending(a => a.LastPomodoro.Start.Value)
                                 .Take(20)
            };

            //last active tasks
            dashboard.LastActiveTasks = new PomodoroContainerDateViewModel
            {
                HeaderTitle    = "Last Active Tasks",
                TableId        = "last-active-tasks",
                IconCssClass   = "fa-play-circle",
                ReportTypeDate = ReportTypeDate.LastPomodoro,
                RowsPerPage    = 5,
                Type           = PomodoroContainerType.Task,
                Items          = db.GetMyPomodoros(User)
                                 .Where(pm => pm.Status == PomodoroStatus.Completed && pm.Start.HasValue)
                                 .Select(pm => pm.Action.Task)
                                 .Distinct().ToList()
                                 .OrderByDescending(t => t.LastPomodoro.Start.Value)
                                 .Take(20)
            };

            //upcoming deadlines (actions)
            dashboard.UpcomingDeadlines = new PomodoroContainerDateViewModel
            {
                HeaderTitle    = "Upcoming Deadlines",
                TableId        = "upcoming-deadlines",
                IconCssClass   = "fa-clock-o",
                ReportTypeDate = ReportTypeDate.NextDeadline,
                RowsPerPage    = 5,
                Type           = PomodoroContainerType.Action,
                Items          = db.GetMyActions(User)
                                 .Where(a => a.Status == Status.Active && a.Deadline.HasValue)
                                 .ToList()
                                 .OrderBy(a => a.NextDeadline.Value)
                                 .Take(20)
            };

            ////upcoming planified work (actions)
            //dashboard.UpcomingPlanifiedActions = new PomodoroContainerDateViewModel
            //{
            //    HeaderTitle = "Upcoming Planified Actions",
            //    TableId = "upcoming-planified-actions",
            //    IconCssClass = "fa-calendar",
            //    ReportTypeDate = ReportTypeDate.NextPlanifiedPomodoro,
            //    RowsPerPage = 5,
            //    Items = db.GetMyPomodoros(User).ToList()
            //        .Where(pm => pm.CalculatedStatus == PomodoroCalculatedStatus.Planified && pm.Start.HasValue)
            //        .Select(pm => pm.Action)
            //        .Distinct().ToList()
            //        .OrderBy(a => a.NextPlanifiedPomodoro.Start.Value)
            //        .Take(20)
            //};

            //last active actions
            dashboard.LastCreatedActions = new PomodoroContainerDateViewModel
            {
                HeaderTitle    = "Last Created Actions",
                TableId        = "last-created-actions",
                IconCssClass   = "fa-plus-circle",
                ReportTypeDate = ReportTypeDate.LastCreationDate,
                RowsPerPage    = 5,
                Type           = PomodoroContainerType.Action,
                Items          = db.GetMyActions(User)
                                 .Where(a => a.CreationDate.HasValue)
                                 .ToList()
                                 .OrderByDescending(a => a.CreationDateLocal.Value)
                                 .Take(20)
            };

            //work amount (line-chart)
            dashboard.WorkAmountChartViewModel = new MorrisLineChartViewModel
            {
                HeaderTitle = "Work Amount",
                Dates       = db.GetMyPomodoros(User).ToList()
                              .Where(p => p.Start.HasValue && p.CalculatedStatus == LoggableItemCalculatedStatus.Completed)
                              .Select(p => p.StartLocal.Value).AsEnumerable(),
                Interval      = DateInterval.Monthly,
                Label         = "Work units",
                HtmlElementId = "work-amount"
            };

            dashboard.WorkDivisionViewModel = new MorrisDonutChartViewModel
            {
                HeaderTitle = "Work Division",
                Items       = db.GetMyProjects(User)
                              .AsEnumerable()
                              .OrderByDescending(p => p.CompletedPomodorosCount),
                HtmlElementId = "work-division"
            };

            dashboard.MyWorkspace = db.GetMyWorkspace(User);
            //dashboard.WorkDivisionViewModels = new List<MorrisDonutChartViewModel> {
            //    //work project division (donut chart)
            //    new MorrisDonutChartViewModel
            //    {
            //        HeaderTitle = "Projects",
            //        Items = db.GetMyProjects(User),
            //        HtmlElementId = "project-chart"
            //    },
            //    //work task division (donut chart)
            //     new MorrisDonutChartViewModel
            //    {
            //        HeaderTitle = "Tasks",
            //        Items = db.GetMyTasks(User),
            //        HtmlElementId = "task-chart",
            //        UseFullPathItemName = true
            //    }
            //};

            return(View(dashboard));
        }