/// <summary> /// Sends the CopyCourseSection request to the Course API /// </summary> /// <param name="request"><see cref="API.CourseSectionCopyRequestEx">object</see></param> /// <returns><see cref="Response"/>object</returns> private Response ReadCopyCourseSectionResponse(API.CourseSectionCopyRequestEx request) { Response response = new Response(); API.ContentCopyStatus contentCopyStatus = new API.ContentCopyStatus(); try { contentCopyStatus = this.courseAPI.CopyCourseSection(request); XElement xe = XMLHelper.ParseXML<API.ContentCopyStatus>(contentCopyStatus); response.Content = xe.ToString(); response.ContentType = "text/xml"; response.StatusCode = contentCopyStatus.Status; // Handle the Response Status accordingly if (contentCopyStatus.Status == "Ok") response.StatusMessage = "Course Copy Sucessful!"; else if (contentCopyStatus.ID.MappingType == API.MappedIDType.CourseID) response.StatusMessage = String.Format("Course Created, CourseId: {0}. However, the CallNumbers could not be added to the Course since they are already in use.", contentCopyStatus.ID.ID); else response.StatusMessage = contentCopyStatus.Status; } catch (FaultException ex) { // Serialize the Fault details MessageFault detail = ex.CreateMessageFault(); XElement fault = detail.GetDetail<XElement>(); response.Content = fault.ToString(); response.ContentType = "text/xml"; response.StatusCode = fault.Name.LocalName; response.StatusMessage = String.Format("{0}: {1}", fault.Name.LocalName, fault.Value); } catch (Exception ex) { response.Content = ex.Message; response.ContentType = "text/plain"; response.StatusCode = ex.HResult.ToString(); response.StatusMessage = "There was a System Exception! Check the Content from the Response for more details."; } return response; }
/// <summary> /// Sends the UpdateCourseSection request to the Course API /// </summary> /// <param name="request"><see cref="API.CourseSectionUpdateRequest">object</see></param> /// <returns><see cref="Response"/>object</returns> private Response ReadUpdateCourseSectionResponse(API.CourseSectionUpdateRequest request) { Response response = new Response(); API.ContentCopyStatus contentCopyStatus = new API.ContentCopyStatus(); try { contentCopyStatus = this.courseAPI.UpdateCourseSection(request); XElement xe = XMLHelper.ParseXML<API.ContentCopyStatus>(contentCopyStatus); response.Content = xe.ToString(); response.ContentType = "text/xml"; // Handle the Response Status accordingly if (contentCopyStatus.Status == null) { response.StatusCode = "Ok"; response.StatusMessage = String.Format("UpdateCourseSectionRequest was successful! CallNumber: {0}", contentCopyStatus.ID.ID); } else { response.StatusCode = "Failure"; response.StatusMessage = contentCopyStatus.Status; } } catch (FaultException ex) { // Serialize the Fault Details MessageFault detail = ex.CreateMessageFault(); XElement fault = detail.GetDetail<XElement>(); response.Content = fault.ToString(); response.ContentType = "text/xml"; response.StatusCode = fault.Name.LocalName; response.StatusMessage = String.Format("{0}: {1}", fault.Name.LocalName, fault.Value); } catch (Exception ex) { response.Content = ex.Message; response.ContentType = "text/plain"; response.StatusCode = ex.HResult.ToString(); response.StatusMessage = "There was a System Exception! Check the Content from the Response for more details."; } return response; }
/// <summary> /// Sends the CopyCourseSectionAndContent request to the Course API /// </summary> /// <param name="request"><see cref="API.CopyCourseRequestEx">object</see></param> /// <returns><see cref="Response"/>object</returns> private Response ReadCopyCourseSectionAndContentResponse(API.CopyCourseRequestEx request) { Response response = new Response(); API.ContentCopyStatus contentCopyStatus = new API.ContentCopyStatus(); try { contentCopyStatus = this.courseAPI.CopyCourseSectionAndContent(request); XElement xe = XMLHelper.ParseXML<API.ContentCopyStatus>(contentCopyStatus); response.Content = xe.ToString(); response.ContentType = "text/xml"; response.StatusCode = contentCopyStatus.Status; // Handle the Response Status accordingly if (contentCopyStatus.Status == "Ok" && contentCopyStatus.JobStatusID != "0") response.StatusMessage = String.Format("CopyCourseSectionAndContentRequest succesfully submitted for processing! Copy Job ID: {0}. For additional processing information please use the Admin Pages and refer to the Copy Job ID included in this response.", contentCopyStatus.JobStatusID); else if (contentCopyStatus.Status == "Ok" && contentCopyStatus.JobStatusID == "0") response.StatusMessage = String.Format("CopyCourseSectionAndContentRequest was not submitted for processing. Please confirm the DestinationCourseCallNumber is correct and that this Course dose not already contain Course Content. DestinationCourseCallNumber: {0}", request.DestinationCourseIdentifiers[0].ID); else response.StatusMessage = contentCopyStatus.Status; } catch (FaultException ex) { // Serialize the Fault Details MessageFault detail = ex.CreateMessageFault(); XElement fault = detail.GetDetail<XElement>(); response.Content = fault.ToString(); response.ContentType = "text/xml"; response.StatusCode = fault.Name.LocalName; response.StatusMessage = String.Format("{0}: {1}", fault.Name.LocalName, fault.Value); } catch (Exception ex) { response.Content = ex.Message; response.ContentType = "text/plain"; response.StatusCode = ex.HResult.ToString(); response.StatusMessage = "There was a System Exception! Check the Content from the Response for more details."; } return response; }