public void BuildStationViewObject()
        {
            // this test attempts to build a station view object
            // and verify the data properties returned

            // arrange  - build a stations list  - use Texas
            TemplateFull.Models.QclcdEntities db = new TemplateFull.Models.QclcdEntities();
            string stationState = "TX";
            var stations = (from s in db.Stations select s).Where(s => s.StationState.ToUpper().Contains(stationState.ToUpper()));

            // stations have to be sorted before being passed into a paged list
            stations = stations.OrderByDescending(s => s.WbanId);

            // create page number and page size variables
            int pgNum = 1;
            int pgSz = 20;

            // act - create the station view
            IStationView sv = new StationView(stations, pgNum, pgSz);

            // assert - verifiy the properties of the station view
            Assert.IsNotNull(sv);
            Assert.IsInstanceOfType(sv, typeof(IStationView));
            Assert.IsTrue(sv.StationPageList.PageCount > 0);
            Assert.IsTrue(sv.StationPageList.PageSize == 20);
        }
        public ViewResult Index(string sortOrder, string currentFilter, int? page, string stationState)
        {
            // set and preserve selected sort orders
            ViewBag.CurrentSort = sortOrder;
            ViewBag.WbanSortParam = String.IsNullOrEmpty(sortOrder) ? "Wban_Desc" : "";
            ViewBag.StateSortParam = sortOrder == "State" ? "State_Desc" : "State";
            ViewBag.StationNameSortParam = sortOrder == "StationName" ? "StationName_Desc" : "StationName";

            // set and preserve state filter
            if (stationState != null)
            {
                page = 1;
            }
            else
            {
                stationState = currentFilter;
            }

            ViewBag.CurrentFilter = stationState;
            ViewBag.StationState = stationState;

            // get all stations
            var stations = from s in db.Stations select s;

            // set current station state filter
            if (!String.IsNullOrEmpty(stationState))
            {
                stations = stations.Where(s => s.StationState.ToUpper().Contains(stationState.ToUpper()));
            }

            // set selected sort order
            switch (sortOrder)
            {
                case "Wban_Desc":
                    stations = stations.OrderByDescending(s => s.WbanId);
                    break;
                case "State":
                    stations = stations.OrderBy(s => s.StationState);
                    break;
                case "State_Desc":
                    stations = stations.OrderByDescending(s => s.StationState);
                    break;
                case "StationName":
                    stations = stations.OrderBy(s => s.StationName);
                    break;
                case "StationName_Desc":
                    stations = stations.OrderByDescending(s => s.StationName);
                    break;
                default: //WBAN ascending
                    stations = stations.OrderBy(s => s.WbanId);
                    break;
            }

            // set page size and page number
            int pageSize = 20;
            int pageNumber = (page ?? 1);

            // create station view object
            IStationView stationView = new StationView(stations, pageNumber, pageSize);

            // pass station view object to station view
            return View("StationView", stationView);
        }