public async Task GetStudentsPaging() { var students = new List <Student>(); var tasks = new List <Task>(); for (int i = 0; i < 5; ++i) { Student student = CreateRandomStudent(); students.Add(student); tasks.Add(AddStudent(student)); } await Task.WhenAll(tasks); // add all the students in parallel // get first page GetStudentsResponse response = await _fooServiceClient.GetStudents(_courseName, 3); Assert.Equal(3, response.Students.Count); Assert.NotEmpty(response.NextUri); // check that all the students we added are there foreach (var student in response.Students) { Assert.Contains(student, students); } students.RemoveAll(s => response.Students.Contains(s)); // get all the rest response = await _fooServiceClient.GetStudentsByUri(response.NextUri); Assert.Equal(2, response.Students.Count); Assert.Null(response.NextUri); foreach (var student in response.Students) { Assert.Contains(student, students); } }
public GetStudentsResponse GetStudents() { GetStudentsResponse response = new GetStudentsResponse(); response.Students = _dbContext.Student.ToList(); return(response); }
public static async void GetAllStudents() { SchoolServiceSoapClient proxy = new SchoolServiceSoapClient(EndpointConfiguration.SchoolServiceSoap); AddResponse add = await proxy.AddAsync(10, "Vitor"); GetStudentsResponse get = await proxy.GetStudentsAsync(); Console.WriteLine(get.Body.GetStudentsResult); }
public GetStudentsResponse GetStudents() { GetStudentsResponse response = new GetStudentsResponse(); try { response.Students = _context.Student.ToList(); } catch (Exception e) { throw new Exception($"Couldn\'t get students due to: {e.StackTrace} {e.Message}"); } return(response); }
public override Task <GetStudentsResponse> GetStudents(GetStudentsRequest request, ServerCallContext context) { var students = StudentsService.GetStudents().Select(s => new StudentMessage() { Name = s.Name, Address = s.Address, Id = s.Id.ToString(), YearOfBirth = s.YearOfBirth }).ToList(); var response = new GetStudentsResponse(); response.Students.AddRange(students); return(Task.FromResult(response)); }
public async Task <IActionResult> GetStudents(string courseName, string continuationToken, int limit) { GetStudentsResult result = await _studentService.GetStudents(courseName, continuationToken, limit); string nextUri = null; if (!string.IsNullOrWhiteSpace(result.ContinuationToken)) { nextUri = $"api/courses/{courseName}/students?continuationToken={WebUtility.UrlEncode(result.ContinuationToken)}&limit={limit}"; } var response = new GetStudentsResponse { NextUri = nextUri, Students = result.Students }; return(Ok(response)); }
public async Task <GetStudentsResponse> GetStudents() { var response = new GetStudentsResponse { Status = Status.NotAuthorized }; try { var students = await _studentRepository.GetStudents(); var studentsDto = students.MapToDto(_mapper); response.Students = studentsDto; response.Status = Status.Ok; } catch (Exception ex) { response.Status = Status.InvalidData; response.Message = ex.Message; } return(response); }
public async Task GetStudents() { var students = new List <Student>(); var tasks = new List <Task>(); for (int i = 0; i < 5; ++i) { Student student = CreateRandomStudent(); students.Add(student); tasks.Add(AddStudent(student)); } await Task.WhenAll(tasks); // add all the students in parallel GetStudentsResponse response = await _fooServiceClient.GetStudents(_courseName, 5); // check that all the students we added are there foreach (var student in students) { Assert.Contains(student, response.Students); } // check that the list of students in sorted Assert.True(IsSortedInDecreasedOrderOrGrades(response.Students)); }