/// <summary> /// This function prints the information about the appointment on the screen. /// </summary> /// <param name="a_info">It holds the full information of the appointment.</param> private void PrintToForm(FullAppointmentInfo a_info) { // Builds the given information into a string before printing it on the screen. StringBuilder build = new StringBuilder(); build.Append(a_info.Faculty.FirstName + " "); build.Append(a_info.Faculty.LastName + " -> "); build.Append(a_info.Faculty.Email); professorLabel.Text = build.ToString(); build.Clear(); build.Append(a_info.Student.FirstName + " "); build.Append(a_info.Student.LastName + " -> "); build.Append(a_info.Student.Email); attendeeLabel.Text = build.ToString(); build.Clear(); // Prints the labels on the screen. startTimeLabel.Text = a_info.Appointment.StartTime.ToShortDateString() + " " + a_info.Appointment.StartTime.ToShortTimeString(); endTimeLabel.Text = a_info.Appointment.EndTime.ToShortDateString() + " " + a_info.Appointment.EndTime.ToShortTimeString(); }
/// <summary> /// This function calls the server to get more information about the appointment master and student. /// </summary> /// <param name="a_appID">It holds the appointment id that needs to be referred to get more info.</param> /// <returns>Returns the FullAppointmentInfo object that contains the student and professor details.</returns> private FullAppointmentInfo ExecuteGetFullAppointment(int a_appID) { /// Gets the instance of http client to make call to the server. HttpClient client = NetworkClient.getInstance().getHttpClient(); /// Builds the necessary URI for making the call. string uri = BaseConnection.g_appointments + "/" + BaseConnection.g_fullInfo + "/" + a_appID; FullAppointmentInfo fullInfo = null; try { // Gets the response from the server and stores the information to fullInfo if the data is successfully received. var resp = client.GetAsync(uri).Result; if (resp.IsSuccessStatusCode) { fullInfo = resp.Content.ReadAsAsync <FullAppointmentInfo>().Result; } } catch (Exception) { // Prints the error message. Worker.printServerError(this); } return(fullInfo); }
/// <summary> /// This function calls the server to get full information of the appointment and displays it on the screen. /// </summary> /// <param name="a_sender">It is the sender object.</param> /// <param name="a_event">It is the event arguments if exists.</param> private void AppointmentAction_Load(object a_sender, EventArgs a_event) { // Enables the approval tile only if professor is logged into the application. if (m_isStudent) { approveTile.Enabled = false; } // Gets the information of the appointment and prints it on the screen. m_fullApp = ExecuteGetFullAppointment(m_appointment.Id); PrintToForm(m_fullApp); }