//
        // 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 ActionResult Edit(VacancyViewModel vacancyViewModel)
        {
           if (ModelState.IsValid)
            {

                bool bReturn = vacancyService.SaveVacancy(vacancyViewModel.Vacancy);
                return RedirectToAction("VacancyIndex");
            }
            vacancyViewModel.States = StateHelper.GetStates();
            vacancyViewModel.Regions = RegionHelper.GetRegions();
            return View(vacancyViewModel);
        }
 public ActionResult Edit(int id)
 {
     Vacancy vacancy = vacancyService.EditVacancy(id);
     VacancyViewModel vacancyViewModel = new VacancyViewModel();
   //  vacancyViewModel.EmploymentTypes = EmploymentTypeHelper.GetEmploymentTypes();
     vacancyViewModel.States = StateHelper.GetStates();
     vacancyViewModel.Regions = RegionHelper.GetRegions();
     vacancyViewModel.Vacancy = vacancy;
     return View(vacancyViewModel);
 }
 public ActionResult Create()
  {
      VacancyViewModel vacancyViewModel = new VacancyViewModel();
     // vacancyViewModel.EmploymentTypes =  EmploymentTypeHelper.GetEmploymentTypes();
      vacancyViewModel.States = StateHelper.GetStates();
      vacancyViewModel.Regions = RegionHelper.GetRegions();
      return View(vacancyViewModel);
 }
  public ActionResult Create(VacancyViewModel vacancyViewModel)
  {
      vacancyViewModel.Vacancy.DatePosted = DateTime.Now;
     
      if (ModelState.IsValid)
      {
          bool bReturn = vacancyService.CreateVacancy(vacancyViewModel.Vacancy);
          return RedirectToAction("VacancyIndex");
      }
 //     vacancyViewModel.EmploymentTypes = EmploymentTypeHelper.GetEmploymentTypes();
      vacancyViewModel.States = StateHelper.GetStates();
      vacancyViewModel.Regions = RegionHelper.GetRegions();
      return View("Create", vacancyViewModel);
  }