//GET: Volunteer/Details/5 public ActionResult Details(int id) { ShowVolunteer ViewModel = new ShowVolunteer(); string url = "volunteerdata/findvolunteer/" + id; HttpResponseMessage response = client.GetAsync(url).Result; //Catch the status code (200 OK, 301 REDIRECT), etc. if (response.IsSuccessStatusCode) { //Volunteer goes in Data Transfer Object VolunteerDto SelectedVolunteer = response.Content.ReadAsAsync <VolunteerDto>().Result; ViewModel.volunteer = SelectedVolunteer; Debug.WriteLine("SelectedVolunteer:" + SelectedVolunteer.VolunteerHasPic); url = "DepartmentData/FindDepartment/" + SelectedVolunteer.DepartmentID; response = client.GetAsync(url).Result; DepartmentDto SelectedDepartment = response.Content.ReadAsAsync <DepartmentDto>().Result; ViewModel.department = SelectedDepartment; return(View(ViewModel)); } else { return(RedirectToAction("Error")); } }
public ActionResult Show(string id) { //find data about the individual volunteer string main_query = "Select * from Volunteers where VolunteerID = @id"; var pk_parameter = new SqlParameter("@id", id); Volunteer Volunteer = db.Volunteers.SqlQuery(main_query, pk_parameter).FirstOrDefault(); //find data about Applications that this volunteer has applied string application_query = "Select * from Applications where Applications.VolunteerID=@id"; var application_parameter = new SqlParameter("@id", id); List <Application> Applications = db.Applications.SqlQuery(application_query, application_parameter).ToList(); ShowVolunteer viewmodel = new ShowVolunteer(); viewmodel.volunteer = Volunteer; viewmodel.applications = Applications; return(View(viewmodel)); }