public async Task <IActionResult> AddTest([FromBody] Test test) { if (!ModelState.IsValid) { return(BadRequest()); } await _testRepository.AddTestAsync(test); return(Ok(test)); }
public Task <Test> AddTestAsync(AddTestModel model) { if (model.Name == null) { throw new InvalidOperationException("name cannot be null"); } var test = new Test { Name = model.Name, State = model.State, PhoneNumber = model.PhoneNumber, Data = "{\"this\":\"is a test\"}" }; var created = _testRepo.AddTestAsync(test); return(created); }
public async Task <ActionResult <IEnumerable <GetTestDto> > > AddTest(AddTestDto addTestDto) { return(Ok(await _testRepo.AddTestAsync(addTestDto))); }