Exemplo n.º 1
0
        /// <summary>
        /// Display a list of paginated list of hill ascents
        /// </summary>
        /// <param name="orderBy">Field to order by - Date/Hill/Metres/Walk</param>
        /// <param name="page">Current page number in list</param>
        /// <returns></returns>
        public ActionResult Index(string orderBy, int page = 1)
        {
            IQueryable <HillAscent> iqHillAscents;

            // ---Use the walking repository to get a list of all the hill ascents----
            // ---Set up the ordering of the hill ascents------
            switch (orderBy)
            {
            case "DateAsc":
                iqHillAscents = this.repository.GetAllHillAscents().OrderBy(ascent => ascent.AscentDate).ThenBy(ascent => ascent.AscentID);
                this.ViewData["OrderAscDesc"] = "Asc";
                this.ViewData["OrderBy"]      = "Date";
                break;

            case "DateDesc":
                iqHillAscents                 = this.repository.GetAllHillAscents().OrderByDescending(ascent => ascent.AscentDate).ThenByDescending(ascent => ascent.AscentID);
                this.ViewData["OrderBy"]      = "Date";
                this.ViewData["OrderAscDesc"] = "Desc";
                break;

            case "HillAsc":
                iqHillAscents                 = this.repository.GetAllHillAscents().OrderBy(ascent => ascent.Hill.Hillname);
                this.ViewData["OrderBy"]      = "Hill";
                this.ViewData["OrderAscDesc"] = "Asc";
                break;

            case "HillDesc":
                iqHillAscents                 = this.repository.GetAllHillAscents().OrderByDescending(ascent => ascent.Hill.Hillname);
                this.ViewData["OrderBy"]      = "Hill";
                this.ViewData["OrderAscDesc"] = "Desc";
                break;

            case "MetresAsc":
                iqHillAscents                 = this.repository.GetAllHillAscents().OrderBy(ascent => ascent.Hill.Metres);
                this.ViewData["OrderBy"]      = "Metres";
                this.ViewData["OrderAscDesc"] = "Asc";
                break;

            case "MetresDesc":
                iqHillAscents                 = this.repository.GetAllHillAscents().OrderByDescending(ascent => ascent.Hill.Metres);
                this.ViewData["OrderBy"]      = "Metres";
                this.ViewData["OrderAscDesc"] = "Desc";
                break;

            case "WalkAsc":
                iqHillAscents                 = this.repository.GetAllHillAscents().OrderBy(ascent => ascent.Walk.WalkTitle);
                this.ViewData["OrderBy"]      = "Walk";
                this.ViewData["OrderAscDesc"] = "Asc";
                break;

            case "WalkDesc":
                iqHillAscents                 = this.repository.GetAllHillAscents().OrderByDescending(ascent => ascent.Walk.WalkTitle);
                this.ViewData["OrderBy"]      = "Walk";
                this.ViewData["OrderAscDesc"] = "Desc";
                break;

            default:
                this.ViewData["OrderBy"]      = "Date";
                this.ViewData["OrderAscDesc"] = "Asc";
                iqHillAscents = this.repository.GetAllHillAscents().OrderBy(ascent => ascent.AscentDate).ThenBy(ascent => ascent.AscentID);
                break;
            }

            // ----Create a paginated list of the walks----------------
            var iqPaginatedAscents = new PaginatedListMVC <HillAscent>(iqHillAscents, page, HILLASCENTS_PAGE_SIZE, Url.Action("Index", "HillAscent", new { OrderBy = ViewData["OrderBy"] + ViewData["OrderAscDesc"].ToString() }), MAX_PAGINATION_LINKS, "");

            return(View(iqPaginatedAscents));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Show a list of hills by areas
        /// </summary>
        /// <param name="id">ID of area show</param>
        /// <param name="orderBy"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public ActionResult HillsByArea(string id, string orderBy = "NameAsc", int page = 1)
        {
            // var IQHillsInWalkingArea = this.repository.FindHillsByArea(id);

            IQueryable <Hill> iqHillsInWalkingArea;

            if ((orderBy == "NameAsc"))
            {
                iqHillsInWalkingArea     = repository.FindHillsByArea(id).OrderBy(hill => hill.Hillname);
                ViewData["OrderBy"]      = "Name";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((orderBy == "NameDesc"))
            {
                iqHillsInWalkingArea     = repository.FindHillsByArea(id).OrderByDescending(hill => hill.Hillname);
                ViewData["OrderBy"]      = "Name";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((orderBy == "MetresAsc"))
            {
                iqHillsInWalkingArea     = repository.FindHillsByArea(id).OrderBy(hill => hill.Metres);
                ViewData["OrderBy"]      = "Metres";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((orderBy == "MetresDesc"))
            {
                iqHillsInWalkingArea     = repository.FindHillsByArea(id).OrderByDescending(hill => hill.Metres);
                ViewData["OrderBy"]      = "Metres";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((orderBy == "FirstAscentDesc"))
            {
                iqHillsInWalkingArea     = repository.FindHillsByArea(id).OrderByDescending(hill => hill.FirstClimbedDate);
                ViewData["OrderBy"]      = "FirstAscent";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((orderBy == "FirstAscentAsc"))
            {
                iqHillsInWalkingArea     = repository.FindHillsByArea(id).OrderBy(hill => hill.FirstClimbedDate);
                ViewData["OrderBy"]      = "FirstAscent";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((orderBy == "NumberAscentDesc"))
            {
                iqHillsInWalkingArea     = repository.FindHillsByArea(id).OrderByDescending(hill => hill.NumberOfAscents);
                ViewData["OrderBy"]      = "NumberAscent";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((orderBy == "NumberAscentAsc"))
            {
                iqHillsInWalkingArea     = repository.FindHillsByArea(id).OrderBy(hill => hill.NumberOfAscents);
                ViewData["OrderBy"]      = "NumberAscent";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else
            {
                iqHillsInWalkingArea     = repository.FindHillsByArea(id);
                ViewData["OrderBy"]      = "Name";
                ViewData["OrderAscDesc"] = "Asc";
            }

            int    pageSize     = Int32.Parse(WebConfigurationManager.AppSettings["PAGINATION_PAGE_SIZE"]);
            int    maxPageLinks = Int32.Parse(WebConfigurationManager.AppSettings["PAGINATION_MAX_PAGE_LINKS"]);
            string strAreaName  = this.repository.GetWalkAreaNameFromAreaRef(id);

            ViewData["AreaName"] = strAreaName;

            // ----Create a paginated list of hills----------------
            PaginatedListMVC <Hill> iqPaginatedHills = new PaginatedListMVC <Hill>(iqHillsInWalkingArea,
                                                                                   page,
                                                                                   pageSize,
                                                                                   Url.RouteUrl("Default", new { action = "HillsByArea", controller = "Walks" }),
                                                                                   maxPageLinks,
                                                                                   "?OrderBy" + orderBy);

            // -----Pass the paginated list of hills to the view. The view expects a paginated list as its model-----
            return(View(iqPaginatedHills));
        }
Exemplo n.º 3
0
        // -------------------------------------------------------------------------------------
        //  Function: HillInClassification
        //  URL     : /Walks/HillsInClassification/Classref/[Pagenumber]
        //  Descr   : Return a list of hills with classification as specified by id parameter
        //            optional page parameter provides pagination.
        // --------------------------------------------------------------------------------------
        public ActionResult HillsInClassification(string id, string orderBy = "NameAsc", int page = 1)
        {
            if ((id == null))
            {
                ViewData["HillClassName"] = "All Hill Classes";
            }
            else
            {
                ViewData["HillClassName"] = repository.GetHillClassificationName(id);
            }
            // -----Get the full hill classification name and pass it to the view---------------
            // ---Use the walking repository to get a list of all the hills in the specified classification----
            IQueryable <Hill> IQHillsInClassificaton;

            if ((orderBy == "NameAsc"))
            {
                IQHillsInClassificaton   = repository.GetHillsByClassification(id).OrderBy(hill => hill.Hillname);
                ViewData["OrderBy"]      = "Name";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((orderBy == "NameDesc"))
            {
                IQHillsInClassificaton   = repository.GetHillsByClassification(id).OrderByDescending(hill => hill.Hillname);
                ViewData["OrderBy"]      = "Name";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((orderBy == "MetresAsc"))
            {
                IQHillsInClassificaton   = repository.GetHillsByClassification(id).OrderBy(hill => hill.Metres);
                ViewData["OrderBy"]      = "Metres";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((orderBy == "MetresDesc"))
            {
                IQHillsInClassificaton   = repository.GetHillsByClassification(id).OrderByDescending(hill => hill.Metres);
                ViewData["OrderBy"]      = "Metres";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((orderBy == "FirstAscentDesc"))
            {
                IQHillsInClassificaton   = repository.GetHillsByClassification(id).OrderByDescending(hill => hill.FirstClimbedDate);
                ViewData["OrderBy"]      = "FirstAscent";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((orderBy == "FirstAscentAsc"))
            {
                IQHillsInClassificaton   = repository.GetHillsByClassification(id).OrderBy(hill => hill.FirstClimbedDate);
                ViewData["OrderBy"]      = "FirstAscent";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((orderBy == "NumberAscentDesc"))
            {
                IQHillsInClassificaton   = repository.GetHillsByClassification(id).OrderByDescending(hill => hill.NumberOfAscents);
                ViewData["OrderBy"]      = "NumberAscent";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((orderBy == "NumberAscentAsc"))
            {
                IQHillsInClassificaton   = repository.GetHillsByClassification(id).OrderBy(hill => hill.NumberOfAscents);
                ViewData["OrderBy"]      = "NumberAscent";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else
            {
                IQHillsInClassificaton   = repository.GetHillsByClassification(id);
                ViewData["OrderBy"]      = "Name";
                ViewData["OrderAscDesc"] = "Asc";
            }
            object iNumClimbed = IQHillsInClassificaton.Count(hill => hill.NumberOfAscents > 0);

            ViewData["NumberClimbed"] = iNumClimbed;

            int pageSize     = Int32.Parse(WebConfigurationManager.AppSettings["PAGINATION_PAGE_SIZE"]);
            int maxPageLinks = Int32.Parse(WebConfigurationManager.AppSettings["PAGINATION_MAX_PAGE_LINKS"]);

            // ----Create a paginated list of hills----------------
            PaginatedListMVC <Hill> iqPaginatedHills = new PaginatedListMVC <Hill>(IQHillsInClassificaton,
                                                                                   page,
                                                                                   pageSize,
                                                                                   Url.RouteUrl("Default", new { action = "HillsInClassification", controller = "Walks" }),
                                                                                   maxPageLinks,
                                                                                   "?OrderBy=" + orderBy);


            // -----Pass the paginated list of hills to the view. The view expects a paginated list as its model-----
            return(View(iqPaginatedHills));
        }
Exemplo n.º 4
0
        // -------------------------------------------------------------------------------------
        //  Function: WalksByDate
        //  URL     : /Walks/WalksByDate/OrderBy/{page}
        //  Descr   : Return a list of walks by date, order as per the OrderBy parameter
        // --------------------------------------------------------------------------------------
        public ActionResult WalksByDate(string OrderBy, int page = 1)
        {
            IOrderedQueryable <Walk> iqWalks;

            // ---Use the walking repository to get a list of all the walks----
            // ---Set up the ordering of the walks ------
            if ((OrderBy == "DateAsc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderBy(walk => walk.WalkDate);
                ViewData["OrderBy"]      = "Date";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((OrderBy == "DateDesc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderByDescending(walk => walk.WalkDate);
                ViewData["OrderBy"]      = "Date";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((OrderBy == "TitleAsc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderBy(walk => walk.WalkTitle);
                ViewData["OrderBy"]      = "Title";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((OrderBy == "TitleDesc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderByDescending(walk => walk.WalkTitle);
                ViewData["OrderBy"]      = "Title";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((OrderBy == "AreaAsc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderBy(walk => walk.WalkAreaName);
                ViewData["OrderBy"]      = "Area";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((OrderBy == "AreaDesc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderByDescending(walk => walk.WalkAreaName);
                ViewData["OrderBy"]      = "Area";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((OrderBy == "LengthAsc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderBy(walk => walk.CartographicLength);
                ViewData["OrderBy"]      = "Length";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((OrderBy == "LengthDesc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderByDescending(walk => walk.CartographicLength);
                ViewData["OrderBy"]      = "Length";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((OrderBy == "AscentAsc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderBy(walk => walk.MetresOfAscent);
                ViewData["OrderBy"]      = "Ascent";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((OrderBy == "AscentDesc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderByDescending(walk => walk.MetresOfAscent);
                ViewData["OrderBy"]      = "Ascent";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((OrderBy == "TotalTimeAsc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderBy(walk => walk.WalkTotalTime);
                ViewData["OrderBy"]      = "TotalTime";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((OrderBy == "TotalTimeDesc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderByDescending(walk => walk.WalkTotalTime);
                ViewData["OrderBy"]      = "TotalTime";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((OrderBy == "MovAvgAsc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderBy(walk => walk.MovingAverageKmh);
                ViewData["OrderBy"]      = "MovAvg";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((OrderBy == "MovAvgDesc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderByDescending(walk => walk.MovingAverageKmh);
                ViewData["OrderBy"]      = "MovAvg";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((OrderBy == "OvlAvgAsc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderBy(walk => walk.WalkAverageSpeedKmh);
                ViewData["OrderBy"]      = "OvlAvg";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((OrderBy == "OvlAvgDesc"))
            {
                iqWalks                  = repository.FindAllWalks().OrderByDescending(walk => walk.WalkAverageSpeedKmh);
                ViewData["OrderBy"]      = "OvlAvg";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else
            {
                iqWalks                  = repository.FindAllWalks().OrderBy(walk => walk.WalkDate);
                ViewData["OrderBy"]      = "Date";
                ViewData["OrderAscDesc"] = "Desc";
            }

            int pageSize     = Int32.Parse(WebConfigurationManager.AppSettings["PAGINATION_PAGE_SIZE"]);
            int maxPageLinks = Int32.Parse(WebConfigurationManager.AppSettings["PAGINATION_MAX_PAGE_LINKS"]);

            ViewData["page"]            = page;
            ViewData["pagesize"]        = pageSize;
            ViewData["StartWalkNumber"] = ((page - 1) * pageSize) + 1;

            // ----Create a paginated list of the walks----------------
            var IQPaginatedWalks = new PaginatedListMVC <Walk>(iqWalks, page, pageSize, Url.Action("WalksByDate", "Walks", new { OrderBy = ViewData["OrderBy"].ToString() + ViewData["OrderAscDesc"].ToString() }), maxPageLinks, "");

            // -----Pass the paginated list of walks to the view. The view expects a paginated list as its model-----
            return(View(IQPaginatedWalks));
        }
Exemplo n.º 5
0
        //
        // GET: /Marker/

        public ActionResult Index(string orderBy, int page = 1)
        {
            IQueryable <Marker> iqMarkers;

            // ---Use the walking repository to get a list of all the markers----
            // ---Set up the ordering of the markers------
            // -----Date Ordering-----------
            if ((orderBy == "DateAsc"))
            {
                iqMarkers                = repository.FindAllMarkers().OrderBy(marker => marker.DateLeft).ThenBy(marker => marker.MarkerTitle);
                ViewData["OrderBy"]      = "Date";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((orderBy == "DateDesc"))
            {
                iqMarkers                = repository.FindAllMarkers().OrderByDescending(marker => marker.DateLeft).ThenByDescending(marker => marker.MarkerTitle);
                ViewData["OrderBy"]      = "Date";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((orderBy == "TitleAsc"))
            {
                iqMarkers                = repository.FindAllMarkers().OrderBy(marker => marker.MarkerTitle).ThenBy(marker => marker.DateLeft);
                ViewData["OrderBy"]      = "Title";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((orderBy == "TitleDesc"))
            {
                iqMarkers                = repository.FindAllMarkers().OrderByDescending(marker => marker.MarkerTitle).ThenByDescending(marker => marker.DateLeft);
                ViewData["OrderBy"]      = "Title";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((orderBy == "StatusAsc"))
            {
                iqMarkers                = repository.FindAllMarkers().OrderBy(marker => marker.Status).ThenBy(marker => marker.DateLeft);
                ViewData["OrderBy"]      = "Status";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((orderBy == "StatusDesc"))
            {
                iqMarkers                = repository.FindAllMarkers().OrderByDescending(marker => marker.Status).ThenByDescending(marker => marker.DateLeft);
                ViewData["OrderBy"]      = "Status";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((orderBy == "WalkAsc"))
            {
                iqMarkers                = repository.FindAllMarkers().OrderBy(marker => marker.Walk.WalkTitle).ThenBy(marker => marker.DateLeft);
                ViewData["OrderBy"]      = "Walk";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((orderBy == "WalkDesc"))
            {
                iqMarkers                = repository.FindAllMarkers().OrderByDescending(marker => marker.Walk.WalkTitle).ThenByDescending(marker => marker.DateLeft);
                ViewData["OrderBy"]      = "Walk";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else if ((orderBy == "WalkAreaAsc"))
            {
                iqMarkers                = repository.FindAllMarkers().OrderBy(marker => marker.Walk.Area.Areaname).ThenBy(marker => marker.DateLeft);
                ViewData["OrderBy"]      = "WalkArea";
                ViewData["OrderAscDesc"] = "Asc";
            }
            else if ((orderBy == "WalkAreaDesc"))
            {
                iqMarkers                = repository.FindAllMarkers().OrderByDescending(marker => marker.Walk.Area.Areaname).ThenByDescending(marker => marker.DateLeft);
                ViewData["OrderBy"]      = "WalkArea";
                ViewData["OrderAscDesc"] = "Desc";
            }
            else
            {
                // ----Default to order by date ascending----
                ViewData["OrderBy"]      = "Date";
                ViewData["OrderAscDesc"] = "Desc";
                iqMarkers = repository.FindAllMarkers().OrderByDescending(marker => marker.DateLeft).ThenByDescending(marker => marker.MarkerTitle);
            }
            // ----Create a paginated list of the walks----------------
            var iqPaginatedMarkers = new PaginatedListMVC <Marker>(iqMarkers, page, MARKERS_PAGE_SIZE, Url.Action("Index", "Marker", new { OrderBy = ViewData["OrderBy"] + ViewData["OrderAscDesc"].ToString() }), MAX_PAGINATION_LINKS, "");

            return(View(iqPaginatedMarkers));
        }