public StudentSectionAttendanceEvent Build() { var studentSectionAttendanceEvent = new StudentSectionAttendanceEvent { AttendanceEventCategoryDescriptorId = _attendanceEventCategoryDescriptorId, SchoolYear = _schoolYear }; if (_student != null) { studentSectionAttendanceEvent.StudentUSI = _student.StudentUSI; studentSectionAttendanceEvent.Student = _student; } if (_section != null) { studentSectionAttendanceEvent.SchoolId = _section.SchoolId; studentSectionAttendanceEvent.SchoolYear = _section.SchoolYear; studentSectionAttendanceEvent.TermTypeId = _section.TermTypeId; studentSectionAttendanceEvent.LocalCourseCode = _section.LocalCourseCode; studentSectionAttendanceEvent.ClassPeriodName = _section.ClassPeriodName; studentSectionAttendanceEvent.ClassroomIdentificationCode = _section.ClassroomIdentificationCode; } return(studentSectionAttendanceEvent); }
/// <summary> /// Creates or updates resources based on the natural key values of the supplied resource. The POST operation can be used to create or update resources. In database terms, this is often referred to as an "upsert" operation (insert + update). Clients should NOT include the resource "id" in the JSON body because it will result in an error (you must use a PUT operation to update a resource by "id"). The web service will identify whether the resource already exists based on the natural key values provided, and update or create the resource appropriately. /// </summary> /// <param name="body">The JSON representation of the "studentSectionAttendanceEvent" resource to be created or updated.</param> /// <returns>A RestSharp <see cref="IRestResponse"/> instance containing the API response details.</returns> public IRestResponse PostStudentSectionAttendanceEvents(StudentSectionAttendanceEvent body) { var request = new RestRequest("/studentSectionAttendanceEvents", Method.POST); request.RequestFormat = DataFormat.Json; // verify required params are set if (body == null) { throw new ArgumentException("API method call is missing required parameters"); } request.AddBody(body); var response = client.Execute(request); var location = response.Headers.FirstOrDefault(x => x.Name == "Location"); if (location != null && !string.IsNullOrWhiteSpace(location.Value.ToString())) { body.id = location.Value.ToString().Split('/').Last(); } return(response); }
/// <summary> /// Updates or creates a resource based on the resource identifier. The PUT operation is used to update or create a resource by identifier. If the resource doesn't exist, the resource will be created using that identifier. Additionally, natural key values cannot be changed using this operation, and will not be modified in the database. If the resource "id" is provided in the JSON body, it will be ignored as well. /// </summary> /// <param name="id">A resource identifier specifying the resource to be updated.</param> /// <param name="IfMatch">The ETag header value used to prevent the PUT from updating a resource modified by another consumer.</param> /// <param name="body">The JSON representation of the "studentSectionAttendanceEvent" resource to be updated.</param> /// <returns>A RestSharp <see cref="IRestResponse"/> instance containing the API response details.</returns> public IRestResponse PutStudentSectionAttendanceEvent(string id, string IfMatch, StudentSectionAttendanceEvent body) { var request = new RestRequest("/studentSectionAttendanceEvents/{id}", Method.PUT); request.RequestFormat = DataFormat.Json; request.AddUrlSegment("id", id); // verify required params are set if (id == null || body == null) { throw new ArgumentException("API method call is missing required parameters"); } request.AddHeader("If-Match", IfMatch); request.AddBody(body); request.Parameters.First(param => param.Type == ParameterType.RequestBody).Name = "application/json"; var response = client.Execute(request); var location = response.Headers.FirstOrDefault(x => x.Name == "Location"); if (location != null && !string.IsNullOrWhiteSpace(location.Value.ToString())) { body.id = location.Value.ToString().Split('/').Last(); } return(response); }