Exemplo n.º 1
0
        public IHttpActionResult Post(SwitchCommandBindingModel command)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            SwitchCommandBase switchCommand = switchCommandMap[command.Command](command.Guid);

            try
            {
                _mediator.Send(switchCommand);
            }
            catch (Exception)
            {
                return(InternalServerError());
            }

            return(Ok($"{switchCommand.Command.ToString()} command for {command.Guid} sent"));
        }
Exemplo n.º 2
0
        public IActionResult Post(SwitchCommandBindingModel command)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            SwitchCommandBase switchCommand = switchCommandMap[command.Command](command.Guid);

            try
            {
                _mediator.Send(switchCommand);
            }
            catch (Exception e)
            {
                string errorMessage = $"{baseLogString} Post => exception {e.Message}";
                Logger.LogError(errorMessage, e);
                return(StatusCode(500));
            }

            return(Ok($"{switchCommand.Command.ToString()} command for {command.Guid} sent"));
        }