// GET: VolunteerPosition/Details/5
        public ActionResult Details(int id)
        {
            ShowVolunteerPosition ViewModel = new ShowVolunteerPosition();
            string url = "volunteerpositiondata/findvolunteerposition/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            //Catch the status code (200 OK, 301 REDIRECT), etc.

            if (response.IsSuccessStatusCode)
            {
                //VolunteerPosition goes in Data Transfer Object
                VolunteerPositionDto SelectedVolunteerPosition = response.Content.ReadAsAsync <VolunteerPositionDto>().Result;
                ViewModel.volunteerposition = SelectedVolunteerPosition;


                url      = "volunteerpositiondata/finddepartmentforvolunteerposition/" + id;
                response = client.GetAsync(url).Result;
                DepartmentDto SelectedDepartment = response.Content.ReadAsAsync <DepartmentDto>().Result;
                ViewModel.department = SelectedDepartment;

                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        // 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"));
            }
        }
        public ActionResult DeleteConfirm(int id)
        {
            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;
                return(View(SelectedVolunteerPosition));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        public IHttpActionResult GetVolunteerPositions()
        {
            List <VolunteerPosition>    VolunteerPositions    = db.VolunteerPositions.ToList();
            List <VolunteerPositionDto> VolunteerPositionDtos = new List <VolunteerPositionDto> {
            };


            foreach (var VolunteerPosition in VolunteerPositions)
            {
                VolunteerPositionDto NewVolunteerPosition = new VolunteerPositionDto
                {
                    CvpID        = VolunteerPosition.CvpID,
                    Name         = VolunteerPosition.Name,
                    Description  = VolunteerPosition.Description,
                    DepartmentID = VolunteerPosition.DepartmentID
                };
                VolunteerPositionDtos.Add(NewVolunteerPosition);
            }

            return(Ok(VolunteerPositionDtos));
        }
        public IHttpActionResult FindVolunteerPosition(int id)
        {
            //Find the data
            VolunteerPosition VolunteerPosition = db.VolunteerPositions.Find(id);

            //if not found, return 404 status code.
            if (VolunteerPosition == null)
            {
                return(NotFound());
            }


            VolunteerPositionDto VolunteerPositionDto = new VolunteerPositionDto
            {
                CvpID        = VolunteerPosition.CvpID,
                Name         = VolunteerPosition.Name,
                Description  = VolunteerPosition.Description,
                DepartmentID = VolunteerPosition.DepartmentID
            };


            //pass along data as 200 status code OK response
            return(Ok(VolunteerPositionDto));
        }