private void FetchUnassignedTasks() { List <DailyTask> taskModels = db.DailyTasks .Where(p => p.UserId == User.Id) .Where(p => p.Completed == 0) .Where(p => p.Date == null) .ToList <DailyTask>(); UnassignedTasks.Clear(); foreach (var m in taskModels) { UnassignedTasks.Add(m); } }
private void SortList(string sortByParameter) { List <DailyTask> orderedTasks = null; UnassignedTasks.Clear(); switch (sortByParameter) { case "Date added": orderedTasks = db.DailyTasks .Where(p => p.UserId == User.Id) .Where(p => p.Completed == 0) .Where(p => p.Date == null) .OrderBy(s => s.Id) .ToList(); break; case "Category": orderedTasks = db.DailyTasks .Where(p => p.UserId == User.Id) .Where(p => p.Completed == 0) .Where(p => p.Date == null) .OrderBy(s => s.CategoryId) .ToList(); break; case "Deadline": orderedTasks = db.DailyTasks .Where(p => p.UserId == User.Id) .Where(p => p.Completed == 0) .Where(p => p.Date == null) .OrderBy(s => s.Deadline == null) .ThenBy(s => s.Deadline) .ToList(); break; } foreach (var task in orderedTasks) { unassignedTasks.Add(task); } }