public void Test_People_First_Page() { int total; IEnumerable <Person> samplePeople = peoplePresentation.GetPeople(new List <int>() { 1, 2 }, "", "", 0, 2, out total); Assert.NotNull(samplePeople); Assert.Equal(2, samplePeople.Count()); }
public IActionResult GetPeople([FromQuery] QueryPagination page, [FromQuery] QueryFilter filter, [FromQuery] string query = "", [FromQuery] string baseUrl = "") { baseUrl = GetBaseUrl(baseUrl); if (filter.categories == 0) { filter = GetQueryFilter(); } query = GetSearchKey(filter.search, query); if (string.IsNullOrEmpty(baseUrl)) { _logger.Error("baseUrl not been provided"); return(NoContent()); } var schools = _schoolsService.GetSchools(baseUrl, ""); if (IsResourcesRequestValid(filter, schools, new List <int> () { 5, 6 })) { int total; IEnumerable <Person> simplePeople = _peoplePresentation.GetPeople(filter.channelServerIds, baseUrl, query, page.offset, page.limit, out total); var links = string.IsNullOrEmpty(query) ? this.GetLinks(baseUrl, filter, page, query, true, total) : null; if (simplePeople.Count() == 0) { _logger.Information("no people found"); return(NoContent()); } var fullPeople = _peopleRepository.GetPeopleInfo(baseUrl, simplePeople); var dataList = from p in fullPeople select new { id = p.UserId.ToString(), type = "school-messenger.people", attributes = new { firstName = p.FirstName, lastName = p.LastName, jobTitle = p.JobTitle, phoneNumber = p.PhoneNumber, email = p.Email, website = p.Website, twitter = p.Twitter, about = p.Description + p.PersonalMessage, image = p.ImageUrl, name = p.FirstName + " " + p.LastName, description = p.Description, blog = p.Blog, personalMessage = p.PersonalMessage }, relationships = new { categories = new { data = new object[] { new { type = "school-messenger.categories", id = "6" } } }, channels = new { data = new object[] { new { type = "school-messenger.channels", id = p.ServerId.ToString() } } }, } }; return(Ok(new { Data = dataList, Links = links })); } _logger.Error("validation failed"); return(NoContent()); }