private static IEnumerable<Task> AddLocationFilter(string value, List<Task> tasks) { return tasks.Where(task => task.LocationId == value); }
private void BuildListDimensions(List<Task> tasks) { var lists = this._listStoreLocator.GetStore().GetAllLists(); //TODO: add smart lists back once filtering for tasks is working _listCollection = lists .Where(list => list.Smart == false) .Select(list => new Group { Name = list.Name, Order = list.Smart ? 1 : 0, Tasks = tasks.Where( task => ((task.ListId == list.Id) && (task.Completed == null) && (task.Deleted == null)) ).ToList() }).ToList(); this._listCollectionViewModels = new ObservableCollection<TaskGroupViewModel>(); var viewModels = this._listCollection.Select(o => new TaskGroupViewModel(o.Name, o.Order, o.Tasks, ViewTaskCollectionCommand, this.NavigationService, this._synchronizationService)).ToList(); viewModels.ForEach(this._listCollectionViewModels.Add); // Create collection views this._listCollectionViewSource = new CollectionViewSource { Source = this._listCollectionViewModels }; this._listCollectionViewSource.View.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending)); this._listCollectionViewSource.View.CurrentChanged += (o, args) => { this.SelectedGroup = (TaskGroupViewModel)this._listCollectionViewSource.View.CurrentItem; this.SelectedGroupIndex = this._listCollectionViewSource.View.CurrentPosition; }; }
private void BuildLocationDimensions(List<Task> tasks) { var locations = this._locationStoreLocator.GetStore().GetAllLocations(); _locationCollection = locations.Select(location => new Group { Name = location.Name, Order = 0, Tasks = tasks.Where(task => ((task.LocationId == location.Id) && (task.Completed == null) && (task.Deleted == null)) ).ToList() }).ToList(); this._locationCollectionViewModels = new ObservableCollection<TaskGroupViewModel>(); var viewModels = this._locationCollection.Select(o => new TaskGroupViewModel(o.Name, o.Order, o.Tasks, ViewTaskCollectionCommand, this.NavigationService, this._synchronizationService)).ToList(); viewModels.ForEach(this._locationCollectionViewModels.Add); // Create collection views this._locationCollectionViewSource = new CollectionViewSource { Source = this._locationCollectionViewModels }; this._locationCollectionViewSource.View.CurrentChanged += (o, args) => { this.SelectedGroup = (TaskGroupViewModel)this._locationCollectionViewSource.View.CurrentItem; this.SelectedGroupIndex = this._locationCollectionViewSource.View.CurrentPosition; }; }
private void BuildDueByDimensions(List<Task> tasks) { var startOfWeek = DateTime.Now.StartOfWeek(DayOfWeek.Monday); var endOfWeek = DateTime.Now.EndOfWeek(DayOfWeek.Monday); var dueTodayTasks = tasks. Where(task => ((task.Due.AsDateTime(DateTime.MaxValue) <= DateTime.Today) && (task.Completed == null) && (task.Deleted == null))); var dueTomorrowTasks = tasks. Where(task => ((task.Due.AsDateTime(DateTime.MaxValue) == DateTime.Today.AddDays(1)) && (task.Completed == null) && (task.Deleted == null))); var dueThisWeekTasks = tasks. Where(task => (task.Due.AsDateTime(DateTime.MaxValue) >= startOfWeek && task.Due.AsDateTime(DateTime.MaxValue) <= endOfWeek) && (task.Completed == null) && (task.Deleted == null)); var dueNextWeekTasks = tasks. Where(task => (task.Due.AsDateTime(DateTime.MaxValue) >= startOfWeek.AddDays(7) && task.Due.AsDateTime(DateTime.MaxValue) <= endOfWeek.AddDays(7)) && (task.Completed == null) && (task.Deleted == null)); _dueByCollection = new List<Group> { new Group {Name = "Today", Order = 0, Tasks = dueTodayTasks.ToList()}, new Group {Name = "Tomorrow", Order = 1, Tasks = dueTomorrowTasks.ToList()}, new Group {Name = "This Week", Order = 2, Tasks = dueThisWeekTasks.ToList()}, new Group {Name = "Next Week", Order = 3, Tasks = dueNextWeekTasks.ToList()} }; this._dueByCollectionViewModels = new ObservableCollection<TaskGroupViewModel>(); var viewModels = this._dueByCollection.Select(o => new TaskGroupViewModel(o.Name, o.Order, o.Tasks, ViewTaskCollectionCommand, this.NavigationService, this._synchronizationService)).ToList(); viewModels.ForEach(this._dueByCollectionViewModels.Add); // Create collection views this._dueByCollectionViewSource = new CollectionViewSource { Source = this._dueByCollectionViewModels }; this._dueByCollectionViewSource.View.CurrentChanged += (o, args) => { this.SelectedGroup = (TaskGroupViewModel)this._dueByCollectionViewSource.View.CurrentItem; this.SelectedGroupIndex = this._dueByCollectionViewSource.View.CurrentPosition; }; }