Esempio n. 1
0
        // GET: /Sprint/
        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.ProjectSortParm   = (sortOrder == "proj") ? "proj_desc" : "proj";
            ViewBag.StartDateSortParm = (sortOrder == "star") ? "star_desc" : "star";
            ViewBag.EndDateSortParm   = (sortOrder == "end") ? "end_desc" : "end";
            ViewBag.ActionsSortParm   = (sortOrder == "acti") ? "acti_desc" : "acti";
            ViewBag.PomodorosSortParm = (sortOrder == "pomo") ? "pomo_desc" : "pomo";
            ViewBag.EffortSortParm    = (sortOrder == "effo") ? "effo_desc" : "effo";
            ViewBag.ProgressSortParm  = (sortOrder == "prog") ? "prog_desc" : "prog";

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

            //var sprints = db.Sprints.Include(t => t.Project);
            var sprints = db.GetMySprints(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)
            //{
            //    sprints = sprints.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
            //    sprints = sprints.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
            //    //sprints = sprints.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)
            //{
            //    sprints = sprints.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 sprints, sortOrder);

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

            return(View(sprints.ToPagedList(pageNumber, pageSize)));
        }