public async Task <Guid> PostTestAsync(TestPostDto test) { var newId = await PostGuidEntityAsync(testsEndpoint, test); test.Id = newId.ToString(); return(newId); }
public void PostTest_ShouldFail_GivenNoInspectionId() { // Given var testDto = new TestPostDto { MethodId = Guid.NewGuid().ToString(), MethodRawDataJson = JObject.FromObject(new object()) }; // When // an attempt is made to post test without mandatory attributes AsyncTestDelegate action = async () => await _apiClient.PostTestAsync(testDto); // Then Assert.ThrowsAsync<BadRequestException>(action); }
public async Task <IActionResult> PostTest([FromBody] TestPostDto testDto) { if (null == testDto) { return(InvalidRequestBodyJson(nameof(TestDto))); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var newTest = Mapper.Map <Test>(testDto); newTest.TenantId = _tenantIdProvider.GetTenantId(); await _testService.AddAsync(newTest); return(Created(nameof(GetTest), new CreatedWithGuidDto { Id = newTest.Id })); }