//GET: /Tasks/ProjectTasks?ProjectID=5 public ViewResult ProjectTasks(long projectID, string SelectedStatusID, string SelectedPriorityID, string SelectedUserID, string SelectedSprintID, int? page) { int currentPageIndex = page.HasValue ? page.Value : 1; IList<Task> taskList; UserProfile user = unitOfWork.UserRepository.GetUserByUserID((int)Membership.GetUser(WebSecurity.CurrentUserName).ProviderUserKey); Project project = unitOfWork.ProjectRepository.Find(projectID); ViewBag.TaskStatus = GetAllStatus(projectID); ViewBag.PossiblePriorities = GetallPriority(); ViewBag.PossibleSprints = GetallSprints(projectID); ViewBag.PossibleUsers = GetAllUser(projectID); ViewBag.CurrentProject = project; ViewBag.PageTitle = "Task List"; Search search = new Search(); ViewData["CurrentProjectID"] = project.ProjectID; ViewData["SelectedStatusID"] = SelectedStatusID; ViewData["SelectedPriorityID"] = SelectedPriorityID; ViewData["SelectedUserID"] = SelectedUserID; ViewData["SelectedSprintID"] = SelectedSprintID; search.SelectedProjectID = project.ProjectID; if (!string.IsNullOrEmpty(SelectedStatusID)) search.SelectedStatusID = Convert.ToInt64(SelectedStatusID); if (!string.IsNullOrEmpty(SelectedPriorityID)) search.SelectedPriorityID = Convert.ToInt64(SelectedPriorityID); if (!string.IsNullOrEmpty(SelectedUserID)) search.SelectedUserID = Convert.ToInt64(SelectedUserID); if (!string.IsNullOrEmpty(SelectedSprintID)) search.SelectedSprintID = Convert.ToInt64(SelectedSprintID); taskList = GetTasks(search); ViewBag.SearchObj = search; return View(taskList.ToPagedList(currentPageIndex, defaultPageSize)); }
public List<Task> GetBySearchCriteria(Search search) { List<Task> taskList = new List<Task>(); taskList = context.Tasks.Where(t => t.ProjectID == search.SelectedProjectID && ((search.SelectedStatusID == null && t.ProjectStatus.Name.ToLower() != "closed") || t.ProjectStatusID == search.SelectedStatusID) && (search.SelectedPriorityID == null || t.PriorityID == search.SelectedPriorityID) && (search.SelectedSprintID == null || t.SprintID == search.SelectedSprintID) && (search.SelectedUserID == null || t.Users.Any(u => u.UserId == search.SelectedUserID)) && (t.ParentTaskId == null) ).ToList(); return taskList; }