public async Task <ActionResult <RestClient> > CreateItemAsync(RestClientDto itemDto) { RestClient item = new RestClient() { Id = Guid.NewGuid(), EndPoint = itemDto.EndPoint, HttpMethod = (HttpVerb)itemDto.HttpMethod }; await _repository.CreateItemAsync(item); return(Ok(item));//CreatedAtAction(nameof(GetItemAsync), new { id = item.Id }); //item.AsDto()); }
public async Task <ActionResult <List <JsonDocument> > > GetDataRepo([FromBody] RestClientDto item) { HttpResponseMessage streamTask = new HttpResponseMessage(); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/vnd.github.v3+json")); client.DefaultRequestHeaders.Add("User-Agent", ".NET Foundation Repository Reporter"); if (item.HttpMethod == 0) { // get Request streamTask = await getMockService(item.EndPoint); } if (item.HttpMethod == 1) { // post streamTask = postMockService(item.EndPoint, item.Parameter); } if (item.HttpMethod == 2) { // put streamTask = await putMockService(item.EndPoint, item.Parameter); } if (item.HttpMethod == 3) { // delete streamTask = await deleteMockService(item.EndPoint); } if (!streamTask.IsSuccessStatusCode) { throw new Exception(streamTask.ToString()); } var responsemessage = streamTask.Content.ReadAsStringAsync().Result; dynamic author = JsonConvert.DeserializeObject(responsemessage); if (responsemessage is null) { return(NotFound()); } return(Ok(responsemessage)); }