public ActionResult SearchResults(string q, int?page = 0)
        {
            if (string.IsNullOrEmpty(q))
            {
                q = "";
            }
            List <ListBeveragesViewModel> model = new List <ListBeveragesViewModel>();

            var beverages = ListOfBeverages.TopAlcoholicDrinksUk();

            foreach (var beverage in beverages.Where(x => string.Equals(x.Type, q, StringComparison.CurrentCultureIgnoreCase)))
            {
                string beverageName = beverage.Beverage;
                string beverageType = beverage.Type;

                model.Add(new ListBeveragesViewModel(beverageName, beverageType));
            }

            int totalNumberOfRecords = model.Count;

            int numberOfRecordsPerPage   = 5;
            var numberOfRecordsToDisplay = new PagerHelper.Pagination(totalNumberOfRecords, page, numberOfRecordsPerPage);

            var displayResults = new DisplayPagerViewModel
            {
                DisplaySearchResults = model.Skip((numberOfRecordsToDisplay.CurrentPage - 1) * numberOfRecordsToDisplay.PageSize).Take(numberOfRecordsToDisplay.PageSize).ToList(),
                Pager           = numberOfRecordsToDisplay,
                NumberOfResults = model.Count
            };

            return(View("~/Views/Pager/SearchResults.cshtml", displayResults));
        }
        public ActionResult Home()
        {
            var drinks = ListOfBeverages.TopAlcoholicDrinksUk();

            //Loop over all drinks and count number
            int counterOne = 0;

            for (var i = 0; i < drinks.Count; i++)
            {
                counterOne++;
            }

            //Loop over all drinks and stop at 10
            List <int> counterTwo = new List <int>();

            for (var i = 0; i < drinks.Count; i++)
            {
                if (i < 10)
                {
                    counterTwo.Add(i);
                }
                else
                {
                    break;
                }
            }

            DateTime   currentDate = DateTime.Now;
            DateTime   pastDate    = DateTime.Now.AddYears(-121);
            List <int> yearList    = new List <int>();

            //Loop over current date and get the last 121 years in Asc order
            for (int counter = pastDate.Year; counter <= DateTime.Now.Year; counter++)
            {
                yearList.Add(counter);
            }



            DateTime dt = new DateTime(1, 1, 1);

            TimeSpan span  = currentDate - pastDate;
            int      years = (dt + span).Year;

            List <string> yearDesc = new List <string>();

            //Loop over current date and get the last 121 years in Desc order
            for (int i = 0; i < years; i++)
            {
                yearDesc.Add(currentDate.AddYears(-i).ToString("yyyy"));
            }

            //Get 6 random numbers
            List <int> lstNumbers = new List <int>();

            lstNumbers.Clear();

            for (int i = 0; i <= 6; i++)
            {
                lstNumbers.Add(GetRandomRangeNumber(1, 10));
            }


            //Loop descending
            List <int> lstNumbersDesc = new List <int>();

            for (int i = 10; i > 0; i--)
            {
                lstNumbersDesc.Add(i);
            }

            TempData["allDrinks"]       = counterOne;
            TempData["firstTenDrinks"]  = counterTwo;
            TempData["LoopYears"]       = yearList;
            TempData["LoopYearsDesc"]   = yearDesc;
            TempData["LoopNumbersDesc"] = lstNumbersDesc;

            //Because we start at year 1 for the Gregorian calendar, we must subtract a year here.
            TempData["YearsText"]   = $"There are {yearList.Count - 1} years between {pastDate.Year} and {DateTime.Now.Year}";
            TempData["RandNumbers"] = lstNumbers.OrderBy(x => x);

            //Get 6 random numbers and check for duplicates, if any found re-run the loop
            TempData["RandomNoDups"] = GetRandonNUmbersNoDuplicates().OrderBy(x => x);

            return(View());
        }