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

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


            if (response.IsSuccessStatusCode)
            {
                //Put data into volunteer data transfer object
                VolunteerDto SelectedVolunteer = response.Content.ReadAsAsync <VolunteerDto>().Result;
                ViewModel.volunteer = SelectedVolunteer;

                //get information about departments this volunteer could also be in
                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 Update(string id)
        {
            string          query           = "select * from Volunteers where VolunteerID= @id";
            var             parameter       = new SqlParameter("@id", id);
            Volunteer       volunteer       = db.Volunteers.SqlQuery(query, parameter).FirstOrDefault();
            UpdateVolunteer updateVolunteer = new UpdateVolunteer();

            updateVolunteer.Volunteer = volunteer;
            return(View(updateVolunteer));
        }
        //GET: Volunteer/Create
        public ActionResult Create()
        {
            UpdateVolunteer ViewModel = new UpdateVolunteer();
            //get information about departments this volunteer could also be in
            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 UpdateVolunteer(string id, string firstName, string lastName, string phone, string email, string active, string hoursWorked, string position)
        {
            if (NumberValidation(id) && NameValidation(firstName) && NameValidation(lastName) && PhoneValidation(phone) && EmailValidation(email) && NumberValidation(hoursWorked) && NameValidation(position))
            {
                int myID          = Int32.Parse(id);
                int myHoursWorked = Int32.Parse(hoursWorked);

                bool myActive = false;
                if (active == "True" || active == "true")
                {
                    myActive = true;
                }

                UpdateVolunteer x = new UpdateVolunteer();
                x.Update_Volunteer(myID, firstName, lastName, phone, email, myActive, myHoursWorked, position);

                return(new EmptyResult());
            }
            else
            {
                return(Json(new { status = "error", message = "invalid information entered" }));
            }
        }