public async Task <IActionResult> GetByIdAsync(int Id) { _logger.LogInformation("Get Script with id : {scriptid}", Id); try { var script = await _scriptService.GetByIdAsync(Id); var model = _mapper.Map <ScriptModel>(script); _logger.LogInformation("Retrieved script : {scriptName}", model.Name); return(Ok(model)); } catch (AppException ex) { _logger.LogError(ex, "Failed to get script"); return(BadRequest(new { message = "Failed to get script" })); } catch (Exception ex) { _logger.LogError(ex, "Fatal failure"); return(StatusCode(StatusCodes.Status500InternalServerError, new { message = "Fatal internal error. Please contact administrator" })); } }