Ejemplo n.º 1
0
        public ActionResult GetById(int?id)    //<Command>
        {
            _telemetryClient.TrackEvent("Logging - in GetById (controller) | telemetry");
            _logger.LogInformation("Logging - in GetById (controller) | serilog");
            if (id == null)
            {
                return(BadRequest());
            }

            try
            {
                var response = _commander.GetCommandById(id);
                if (response == null)
                {
                    _telemetryClient.TrackEvent("Logging - Id not valid (controller) | telemetry");
                    _logger.LogInformation("Logging - Id not valid try (controller) | serilog");
                    return(NotFound());
                }
                var result = _mapper.Mapper.Map <CommandDTO>(response);
                return(Ok(result));
            }
            catch (Exception)
            {
                _telemetryClient.TrackEvent("Logging - GetById (controller) | telemetry");
                _logger.LogInformation("Logging - Bad request (controller) | serilog");
                return(BadRequest());
            }
        }