//
        // GET: /Vacancy/

        public ViewResult Index(int page =1)
        {
            int totalItems = 0;
            List<Vacancy> vacancyList = new List<Vacancy>();
         //   vacancyList = vacancyService.GetVacancies().ToList();
            vacancyList = vacancyServiceReference.GetVacancies().ToList();
            totalItems = vacancyList.Count;
            VacancyViewModel vacancyViewModel = new VacancyViewModel();
            vacancyViewModel.Vacancies = new List<Vacancy>();                                       
            vacancyViewModel.Vacancies = (vacancyList
                                                     .OrderByDescending(v => v.VacancyId)
                                                     .Skip((page - 1) * PageSize)
                                                     .Take(PageSize).ToList());
            var pagingInfo = new PagingInfo
                                        {
                                            CurrentPage = page,
                                            ItemsPerPage = PageSize,
                                            TotalItems = totalItems
                                        };
            vacancyViewModel.PagingInfo = pagingInfo;                                       
                                                       
                                                    
     
            return View(vacancyViewModel);
        }
       public static MvcHtmlString PageLinks(this HtmlHelper html, PagingInfo pagingInfo, Func<int,string> pageUrl)
       {
           StringBuilder sb = new StringBuilder();
           for (int i = 1; i <= pagingInfo.TotalPages; i++)
           {
               TagBuilder tag = new TagBuilder("a");
               tag.MergeAttribute("href", pageUrl(i));
               tag.InnerHtml = i.ToString();
               if (i == pagingInfo.CurrentPage)
               {
                   tag.AddCssClass("selected");
               }
               sb.Append(tag.ToString());
           }


           return MvcHtmlString.Create(sb.ToString());
       }