public async Task <IActionResult> CreateTestResult([FromBody] TestResultResource resource) { var testResult = _mapper.Map <TestResultResource, TestResult>(resource); _repository.Add(testResult); await _unitOfWork.CompleteAsync(); var result = _mapper.Map <TestResult, TestResultResource>(testResult); return(Ok(result)); }
public async Task <ICommandResult <TestResult> > ExecuteAsync(CreateTestResultCommand command) { var testResult = await CreateTestResultAsync(command); await _testResultRepository.Add(testResult); return(new CommandResult <TestResult>(true, testResult)); }
public async Task <IActionResult> CreateTestResult([FromBody] TestResultResource testResultResource) { var testResult = _mapper.Map <TestResultResource, TestResult>(testResultResource); var existsResult = await _repository.GetIfExists(testResult); if (existsResult == null) { _repository.Add(testResult); } else { testResult = _mapper.Map <TestResultResource, TestResult>(testResultResource, existsResult); _repository.Update(testResult); } var result = _mapper.Map <TestResult, TestResultResource>(testResult); await _unitOfWork.CompleteAsync(); return(Ok(result)); }