예제 #1
0
        public TechnicianWorkOrderListModel GetSortedPMWorkOrders(string selectedSort, string sortDirection, string assetId)
        {
            if (string.IsNullOrEmpty(sortDirection))
            {
                sortDirection = DefaultSortDirection;
            }
            var model = new TechnicianWorkOrderListModel {
                WorkOrders = new List <TechnicianWorkOrderListItem>(), SortOptions = GetPMSortOptions(), SelectedSort = selectedSort, SelectedAssetKey = assetId
            };
            var techWorkOrders = (new TechnicianWorkOrderFactory(Session[Constants.Security.MaintenanceConnectionStringSessionVariableName].ToString(),
                                                                 Session[Constants.Security.ConnectionStringSessionVariableName].ToString())).GetTechnicianPMWorkOrders(CurrentCity.Id);

            //now we have to sort based on thier selection. if nothing was selected, sort by deadline
            //determine the sort direction we need
            //always sort byt he default sort after the initial sort
            techWorkOrders = techWorkOrders.OrderBy(selectedSort + " " + sortDirection).ToList();

            //if the assetId is passed in, filter by those items
            if (!string.IsNullOrEmpty(assetId))
            {
                var ids = assetId.Split('|');
                //make sure we have the values we expect.
                if (ids.Count() == 3)
                {
                    var areaid  = ids[1];
                    var assetid = ids[2];
                    //split it here, make sure they match the area/asset selected
                    techWorkOrders.RemoveAll(x => !(x.AssetId == areaid && x.AreaId == assetid));
                }
            }
            //add the sorted / filtered ones back to the model
            model.WorkOrders = techWorkOrders;
            //set the sorts for back purposes from the details page
            ViewBag.SortOrder     = selectedSort;
            ViewBag.SortDirection = sortDirection;
            ViewBag.AssetId       = assetId;
            return(model);
        }
예제 #2
0
        public TechnicianWorkOrderListModel GetSortedWorkOrders(string selectedSort, string sortDirection)
        {
            if (string.IsNullOrEmpty(sortDirection))
            {
                sortDirection = DefaultSortDirection;
            }
            var model = new TechnicianWorkOrderListModel {
                WorkOrders = new List <TechnicianWorkOrderListItem>(), SortOptions = GetSortOptions(), SelectedSort = selectedSort
            };
            var techWorkOrders = (new TechnicianWorkOrderFactory(Session[Constants.Security.MaintenanceConnectionStringSessionVariableName].ToString(),
                                                                 Session[Constants.Security.ConnectionStringSessionVariableName].ToString())).GetTechnicianWorkOrders(CurrentCity.Id, WebSecurity.CurrentUserId);

            //now we have to sort based on thier selection. if nothing was selected, sort by deadline
            //determine the sort direction we need
            //always sort byt he default sort after the initial sort
            techWorkOrders = techWorkOrders.OrderBy(selectedSort + " " + sortDirection).ToList();

            //add the sorted ones back to the model
            model.WorkOrders = techWorkOrders;
            //set the sorts for back purposes from the details page
            ViewBag.SortOrder     = selectedSort;
            ViewBag.SortDirection = sortDirection;
            return(model);
        }