public async Task DeleteGeolocationDataByIP_WithIPParameter_ReturnsOkObjectResult() { var ip = "89.64.27.223"; var ipDataDTO = new IPDataDTO { IPParameter = ip }; var contents = new StringContent(JsonConvert.SerializeObject(ipDataDTO), Encoding.UTF8, "application/json"); await _client.PostAsync($"/IP/AddGeolocationDataByIP", contents); HttpRequestMessage request = new HttpRequestMessage { Content = contents, Method = HttpMethod.Delete, RequestUri = new Uri("/IP/DeleteGeolocationDataByIP", UriKind.Relative) }; var response = await _client.SendAsync(request); response.EnsureSuccessStatusCode(); var responseResult = await response.Content.ReadAsStringAsync(); responseResult.Should().Contain("Entry found in DB. Deletion completed"); }
public async Task AddGeolocationDataByIP_WithIPParameter_ReturnsOkObjectResult() { var ip = "89.64.27.223"; var ipDataDTO = new IPDataDTO { IPParameter = ip }; var contents = new StringContent(JsonConvert.SerializeObject(ipDataDTO), Encoding.UTF8, "application/json"); var response = await _client.PostAsync($"/IP/AddGeolocationDataByIP", contents); response.EnsureSuccessStatusCode(); var responseResult = await response.Content.ReadAsStringAsync(); responseResult.Should().Contain("Adding new entry based on paramter was successfull"); }
public async Task <IActionResult> DeleteGeolocationDataByIP([FromBody] IPDataDTO ip) { var result = await _mediator.Send(new DeleteIPCommand(ip.IPParameter)); return(Ok(result)); }
public async Task <IActionResult> AddGeolocationDataByIP([FromBody] IPDataDTO ip) { var result = await _mediator.Send(new AddIPCommand { IPParameter = ip.IPParameter }); return(Ok(result)); }