public async Task <IActionResult> AddTestResult([FromBody] TestResultViewModel formdata) { try { if (formdata == null) { return(BadRequest(new JsonResult(new { message = "object sent from client is null." }))); } else if (!ModelState.IsValid) { return(BadRequest("Invalid model object sent from client.")); } var testResult = _mapper.Map <TestResultDto>(formdata); var testResultData = await _testResultService.AddTestResult(testResult); if (testResultData == -1) { return(NotFound()); } testResult.Id = testResultData; var addedTestresult = _mapper.Map <TestResultViewModel>(testResult); return(CreatedAtAction(nameof(GetTestResult), new { id = testResultData }, addedTestresult)); } catch (Exception e) { return(StatusCode(500, $"Something went wrong inside add testresult action: {e.Message}")); } }
public async Task <IActionResult> AddTestResult([FromBody] TestResultRequest testResultRequest) { await _testResultService.AddTestResult(testResultRequest); return(Ok(new Response(true, HttpStatusCode.OK))); }