/// <summary> /// Generates a UpdateCourseSection Course API Request /// </summary> /// <param name="request"><see cref="UpdateCourseSectionRequest">object</see></param> /// <returns><see cref="Response"/>object</returns> public Response UpdateCourseSection(UpdateCourseSectionRequest request) { API.CourseSectionUpdateRequest updateCourseSection = null; Response response = null; try { // Validate the Request Object ValidateUpdateCourseSectionRequest(request); // Intialize and Set the CopyCourseSectionRequest updateCourseSection = SetUpdateCourseSectionRequest(request); // Build the Response object from the SOAP response response = ReadUpdateCourseSectionResponse(updateCourseSection); } catch (Exception ex) { Logger.Error("Exception from UpdateCourseSection: ", ex); throw; } finally { if (this.courseAPI != null) this.courseAPI.Close(); } return response; }
/// <summary> /// Performs validation and business logic checks on the UpdateCourseSectionRequest values /// </summary> /// <param name="request"><see cref="UpdateCourseSectionRequest">object</see></param> /// <exception cref="ArgumentNullException">Thrown when a required value is not set in the <see cref="UpdateCourseSectionRequest">object</see></exception> /// <exception cref="ArgumentException">Thrown when there is a conflict between the values in the <see cref="UpdateCourseSectionRequest">object</see></exception> /// <exception cref="ArgumentOutOfRangeException">Thrown when a value in the <see cref="UpdateCourseSectionRequest">object</see> is invalid.</exception> private static void ValidateUpdateCourseSectionRequest(UpdateCourseSectionRequest request) { // Perform a Parameter Validation and Business Logice Check on the Request if (request.ClientString == null) throw new ArgumentNullException("The ClientString value is required. Please correct and try the reqeust again."); else if (request.PrimaryClientSortString == null) throw new ArgumentNullException("The PrimaryClientSortString value is required. Please correct and try the request again."); else if (request.DestinationCourseCallNumber == null) throw new ArgumentNullException("The DestinationCourseCallNumber value is required. Please correct and try the request again."); else if (request.DestinationSectionNumber > 255) throw new ArgumentOutOfRangeException("The DestinationSectionNumber has a Maximum allowed Value of 255. Please correct and try the request again."); }
/// <summary> /// Creates the XML payload for the UpdateCourseSection Course API Request /// </summary> /// <param name="request"><see cref="UpdateCourseSectionRequest">object</see></param> /// <returns><see cref="API.CourseSectionUpdateRequest"/>object</returns> private API.CourseSectionUpdateRequest SetUpdateCourseSectionRequest(UpdateCourseSectionRequest request) { // Initialize and Set the UpdateCourseSectionRequest API.CourseSectionUpdateRequest updateCourseSection = new API.CourseSectionUpdateRequest(); updateCourseSection.ClientString = request.ClientString; updateCourseSection.DestinationCourseIdentifier = new API.CourseIdentifier(); // If Adding CallNumbers set CourseCallNumbers object accordingly if (request.AddCourseCallNumbers != null) { // Initialize the CourseCallNumbers Object updateCourseSection.DestinationCourseIdentifier.CourseCallNumbers = new API.CourseCallNumber[request.AddCourseCallNumbers.Length]; // Loop through the Call Numbers in the Request for (int i = 0; i < request.AddCourseCallNumbers.Length; i++) { updateCourseSection.DestinationCourseIdentifier.CourseCallNumbers[i] = new API.CourseCallNumber(); updateCourseSection.DestinationCourseIdentifier.CourseCallNumbers[i].ClientCallNumber = request.AddCourseCallNumbers[i]; } } // Set the DestinationCourseCallNumber updateCourseSection.DestinationCourseIdentifier.ID = request.DestinationCourseCallNumber; updateCourseSection.DestinationCourseIdentifier.MappingType = API.MappedIDType.CallNumber; updateCourseSection.DestinationDisplayCourseCode = request.DestinationDisplayCourseCode; updateCourseSection.DestinationSectionDescription = request.DestinationSectionDescription; updateCourseSection.DestinationSectionNumber = request.DestinationSectionNumber; updateCourseSection.DestinationSectionTitle = request.DestinationSectionTitle; updateCourseSection.PrimaryClientSortString = request.PrimaryClientSortString; return updateCourseSection; }