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")); }
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")); }