示例#1
0
        public ActionResult CreateCommand(CommandDTO commandDTO) //<CommandDTO>
        {
            _telemetryClient.TrackEvent("Logging - in CreateCommand (controller) | telemetry");
            _logger.LogInformation("Logging - in CreateCommand (controller) | serilog");

            //throw new Exce

            if (ModelState.IsValid)
            {
                _telemetryClient.TrackEvent("Logging - Model Valid in CreateCommand (controller) | telemetry");
                _logger.LogInformation("Logging - Model Valid in CreateCommand (controller) | serilog");

                var details  = _mapper.Mapper.Map <CommandDTO, Command>(commandDTO);
                var response = _commander.CreateCommand(details);

                var result = _mapper.Mapper.Map <Command, CommandDTO>(response);

                return(new OkObjectResult(result));
            }
            else
            {
                _telemetryClient.TrackEvent("Logging - Model Not Valid in CreateCommand (controller) | telemetry");
                _logger.LogInformation("Logging - Model Not Valid in CreateCommand (controller) | serilog");
                //throw new Exception("not correct tsm");
                return(BadRequest());
            }
        }