protected void SetPoem(People people, HttpClient client) { if (people == null || client == null) { return; } PeopleService.ResponseResult(URL_POEMS + $"{people.Id}", client); // вставка поэмы }
protected void SetQuote(People people, HttpClient client) { if (people == null || client == null) { return; } var result = PeopleService.ResponseResult(URL_QUOTE, client); // получение quote if (result.IsSuccessStatusCode) { people.Quote = result.Content.ReadAsStringAsync().Result.Replace("\"", "").Replace("\n", ""); } }
public People GetNewPeople() { People newPeople = null; using (var client = new HttpClient()) { var resultUser = PeopleService.ResponseResult(URL_USER, client); // получение randomuser if (resultUser.IsSuccessStatusCode) { newPeople = peopleService.MappingPeople(resultUser.Content.ReadAsStringAsync().Result, PARENT_NODE_USER); SetQuote(newPeople, client); if (newPeople != null) { newPeople.Id = peopleDB.Peoples.Add(newPeople).Id; peopleDB.SaveChanges(); SetPoem(newPeople, client); } } } return(newPeople); }