public async Task <IActionResult> UpdateTestCase(long testCaseId, [FromBody] TestCaseResource testCaseResource) { try { if (!string.IsNullOrEmpty(testCaseResource.AutomationId)) { var automationIdInUse = await _repository.CheckAutomationId(testCaseId, testCaseResource.AutomationId); } var testCase = await _repository.Get(testCaseId); if (testCase == null) { return(NotFound()); } var result = _mapper.Map <TestCaseResource, TestCase>(testCaseResource, testCase); _repository.Update(result); await _unitOfWork.CompleteAsync(); return(Ok(result)); } catch (Exception err) { return(BadRequest(err)); } }
public async Task <IActionResult> CreateTestCase([FromBody] TestCaseResource resource) { var testCase = _mapper.Map <TestCaseResource, TestCase>(resource); _repository.Add(testCase); await _unitOfWork.CompleteAsync(); var result = _mapper.Map <TestCase, TestCaseResource>(testCase); return(Ok(result)); }
public async Task <IActionResult> UpdateTestCase(long testCaseId, [FromBody] TestCaseResource testCaseResource) { var testCase = await _repository.Get(testCaseId); if (testCase == null) { return(NotFound()); } var result = _mapper.Map <TestCaseResource, TestCase>(testCaseResource, testCase); _repository.Update(result); await _unitOfWork.CompleteAsync(); return(Ok(result)); }