예제 #1
0
        public async Task <IActionResult> GetTestResult(int id)
        {
            try
            {
                var testResult = await _testResultService.Get(id);

                if (testResult == null)
                {
                    return(NotFound());
                }

                return(Ok(testResult));
            }
            catch (Exception e)
            {
                return(StatusCode(500, new JsonResult(new { message = e.Message })));
            }
        }
예제 #2
0
        public IHttpActionResult GetById(int id)
        {
            if (id <= 0)
            {
                return(BadRequest("Incorrect result id."));
            }

            try
            {
                TestResultDTO resultDTO = _resultService.Get(id);

                TestResultModel returnedResult = _mapper.Map <TestResultDTO, TestResultModel>(resultDTO);

                return(Ok(returnedResult));
            }
            catch (EntityNotFoundException)
            {
                return(NotFound());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }