示例#1
0
        public async Task UpdateStudent(string courseName, Student student)
        {
            var body = new UpdateStudentRequestBody
            {
                Name            = student.Name,
                GradePercentage = student.GradePercentage
            };

            string json = JsonConvert.SerializeObject(body);
            HttpResponseMessage responseMessage = await _httpClient.PutAsync($"api/courses/{courseName}/students/{student.Id}", new StringContent(json,
                                                                                                                                                  Encoding.UTF8, "application/json"));

            await EnsureSuccessOrThrow(responseMessage);
        }
示例#2
0
        public async Task <IActionResult> UpdateStudent(string courseName, string studentId, [FromBody] UpdateStudentRequestBody body)
        {
            var student = new Student
            {
                Id              = studentId,
                Name            = body.Name,
                GradePercentage = body.GradePercentage
            };

            await _studentService.UpdateStudent(courseName, student);

            return(Ok());
        }