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); }
private SearchResults SearchProjects(string term = "", SearchResults currentResults = null, Status?status = null) { if (currentResults == null) { currentResults = new SearchResults(); } currentResults.SearchTerm = term; currentResults.ProjectResults = db.GetMyProjects(User) .Where(p => p.Code.ToLower().Contains(currentResults.SearchTerm) || p.Name.ToLower().Contains(currentResults.SearchTerm) || p.Description.ToLower().Contains(currentResults.SearchTerm)) .Where(p => !status.HasValue || p.Status == status.Value) .ToList(); return(currentResults); }
public ActionResult Create(int?projectId, int?collectedThingID, string name) { ViewBag.ProjectID = new SelectList(db.GetMyProjects(User), "ID", "Code", projectId); ViewBag.Name = name; return(View()); }
// 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)); }
// GET: /Project/ public ViewResult Index(string sortOrder, string currentFilter, string searchString, int?page) { ViewBag.CodeSortParm = (sortOrder == "code") ? "code_desc" : "code"; ViewBag.NameSortParm = (sortOrder == "name") ? "name_desc" : "name"; 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.StatusSortParm = (sortOrder == "stat") ? "stat_desc" : "stat"; ViewBag.CreationDateSortParm = (sortOrder == "crea") ? "crea_desc" : "crea"; ViewBag.TasksSortParm = (sortOrder == "task") ? "task_desc" : "task"; ViewBag.ActionsSortParm = (sortOrder == "acti") ? "acti_desc" : "acti"; var projects = db.GetMyProjects(User); //stores the current filter info for the pagination control RouteValueDictionary dict = new RouteValueDictionary(); //initilised with the current sort order dict["CurrentSort"] = sortOrder; if (Request != null) //avoid null reference exceptions when testing { //status filter const string STATUS_PREFIX = "status-"; string[] statusFilter = GetArrayParamsFromRequest(Request.QueryString, STATUS_PREFIX); if (statusFilter.Length > 0) { projects = projects.ToList().AsQueryable() .Where(p => statusFilter .Any(sf => sf.ToLower() == p.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) { projects = projects.ToList().AsQueryable() .Where(p => tagFilter .Any(tf => p.OwnAndInheritedTags //all tags in the filter .Select(tc => tc.Code) //(only tag code list) .Contains(tf)) //contained in the item tags ); //AND Tag Filter //projects = projects.ToList().AsQueryable() // .Where(p => tagFilter // .All(tf => p.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); } ViewBag.IsFiltered = string.IsNullOrEmpty(Request.QueryString["filtering"]) == false || (statusFilter.Length > 0) || (tagFilter.Length > 0); ViewBag.RouteFiltersForPagination = dict; ViewBag.StatusFilter = statusFilter; ViewBag.TagFilter = tagFilter; } //if (searchString != null) //{ // page = 1; //} //else //{ // searchString = currentFilter; //} //ViewBag.CurrentFilter = searchString; ViewBag.AllTags = db.GetMyTags(User).ToArray(); switch (sortOrder) { case "code": projects = projects.OrderBy(p => p.Code); break; case "code_desc": projects = projects.OrderByDescending(p => p.Code); break; case "name": projects = projects.OrderBy(p => p.Name); break; case "name_desc": projects = projects.OrderByDescending(p => p.Name); break; case "last": projects = projects.ToList().AsQueryable().OrderBy(p => p.LastPomodoro.ToDateTicksOrZero()); break; case "last_desc": projects = projects.ToList().AsQueryable().OrderByDescending(p => p.LastPomodoro.ToDateTicksOrZero()); break; case "pomo": projects = projects.ToList().AsQueryable().OrderBy(p => p.CompletedPomodorosCount); break; case "pomo_desc": projects = projects.ToList().AsQueryable().OrderByDescending(p => p.CompletedPomodorosCount); break; case "prog": projects = projects.ToList().AsQueryable().OrderBy(p => p.Progress.ToDecimalOrZero()); break; case "prog_desc": projects = projects.ToList().AsQueryable().OrderByDescending(p => p.Progress.ToDecimalOrZero()); break; case "effo": projects = projects.ToList().AsQueryable().OrderBy(p => p.Effort.ToDecimalOrZero()).ThenBy(p => p.CompletedPomodorosCount); break; case "effo_desc": projects = projects.ToList().AsQueryable().OrderByDescending(p => p.Effort.ToDecimalOrZero()).ThenByDescending(p => p.CompletedPomodorosCount); break; case "stat": projects = projects.ToList().AsQueryable().OrderBy(p => p.CalculatedStatus); break; case "stat_desc": projects = projects.ToList().AsQueryable().OrderByDescending(p => p.CalculatedStatus); break; case "crea": projects = projects.ToList().AsQueryable().OrderBy(p => p.CreationDateLocal.ToTicksOrZero()); break; case "crea_desc": projects = projects.ToList().AsQueryable().OrderByDescending(p => p.CreationDateLocal.ToTicksOrZero()); break; case "task": projects = projects.ToList().AsQueryable().OrderBy(p => p.Tasks.Count()); break; case "task_desc": projects = projects.ToList().AsQueryable().OrderByDescending(p => p.Tasks.Count()); break; case "acti": projects = projects.ToList().AsQueryable().OrderBy(p => p.GetActions().Count()); break; case "acti_desc": projects = projects.ToList().AsQueryable().OrderByDescending(p => p.GetActions().Count()); break; default: projects = projects.ToList().AsQueryable().OrderBy(p => p.Status).ThenByDescending(p => p.LastPomodoro.ToDateTicksOrZero()); break; } int pageSize = 20; int pageNumber = (page ?? 1); return(View(projects.ToPagedList(pageNumber, pageSize))); }