// GET: VolunteerPosition/Edit/8
        public ActionResult Edit(int id)
        {
            UpdateVolunteerPosition ViewModel = new UpdateVolunteerPosition();

            string url = "volunteerpositiondata/findvolunteerposition/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;


            if (response.IsSuccessStatusCode)
            {
                //Put data into volunteerposition data transfer object
                VolunteerPositionDto SelectedVolunteerPosition = response.Content.ReadAsAsync <VolunteerPositionDto>().Result;
                ViewModel.volunteerposition = SelectedVolunteerPosition;

                //get information about departments that may also need this volunteer position
                url      = "departmentdata/listdepartments";
                response = client.GetAsync(url).Result;
                IEnumerable <DepartmentDto> PotentialDepartments = response.Content.ReadAsAsync <IEnumerable <DepartmentDto> >().Result;
                ViewModel.alldepartments = PotentialDepartments;

                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        // GET: VolunteerPosition/Create
        public ActionResult Create()
        {
            UpdateVolunteerPosition ViewModel = new UpdateVolunteerPosition();
            //get information about departments that may also need this volunteer position
            string url = "departmentdata/listdepartments";
            HttpResponseMessage         response             = client.GetAsync(url).Result;
            IEnumerable <DepartmentDto> PotentialDepartments = response.Content.ReadAsAsync <IEnumerable <DepartmentDto> >().Result;

            ViewModel.alldepartments = PotentialDepartments;

            return(View(ViewModel));
        }
        public ActionResult Update(int id)
        {
            VolunteerPosition      selectedVolunteerPosition = db.VolunteerPositions.SqlQuery("select * from VolunteerPositions where VolunteerPositionID=@VolunteerPositionID", new SqlParameter("@VolunteerPositionID", id)).FirstOrDefault();
            List <Department>      departments = db.Departments.SqlQuery("select * from Departments").ToList();
            List <ApplicationUser> volunteers  = db.VolunteerPositions.Where(x => x.VolunteerPositionID == id).SelectMany(c => c.Users).ToList();
            // string userId = User.Identity.GetUserId();
            //ApplicationUser currentUser = db.Users.FirstOrDefault(x => x.Id == userId);

            UpdateVolunteerPosition UpdateVolunteerPositionViewModel = new UpdateVolunteerPosition();

            UpdateVolunteerPositionViewModel.VolunteerPosition = selectedVolunteerPosition;
            UpdateVolunteerPositionViewModel.Departments       = departments;
            UpdateVolunteerPositionViewModel.Users             = volunteers;
            // UpdateJobListingViewModel.User = currentUser;

            return(View(UpdateVolunteerPositionViewModel));
        }