Ejemplo n.º 1
0
        public async Task <IActionResult> PostSMS([FromBody] SendSMSRequest request, CancellationToken cancellationToken)
        {
            Logger.LogInformation(JsonConvert.SerializeObject(request));

            SendSMSCommand command = SendSMSCommand.Create(request);

            await this.CommandRouter.Route(command, cancellationToken);

            return(this.Ok(command.Response));
        }
        public void MessagingCommandHandler_HandleCommand_SendSMSCommand_CommandHandled()
        {
            Mock <IEmailServiceProxy> emailServiceProxy = new Mock <IEmailServiceProxy>();
            Mock <ISMSServiceProxy>   smsServiceProxy   = new Mock <ISMSServiceProxy>();

            MessagingCommandHandler handler = new MessagingCommandHandler(emailServiceProxy.Object, smsServiceProxy.Object);

            SendSMSCommand command = MessagingServiceSMSTestData.GetSendSmsCommand();

            Should.NotThrow(async() => { await handler.Handle(command, CancellationToken.None); });
        }
Ejemplo n.º 3
0
        async public Task <IActionResult> Get(string from, string to, string text)
        {
            var sendSmsCommand = new SendSMSCommand()
            {
                From = from,
                To   = to,
                Text = text
            };
            var result = await mediator.Send(sendSmsCommand);

            return(Ok(Enum.GetName(typeof(RequestResult), result)));
        }
Ejemplo n.º 4
0
        private void AddTask(object sender, EventArgs e)
        {
            var     btn = sender as Button;
            Command cmd = null;

            foreach (var c in AppConfig.BaseCommands)
            {
                if (c.CommandName == CommandList.Text)
                {
                    if (c.ThisType == Command.CommandType.SendSMSCmd)
                    {
                        var scmd = new SendSMSCommand();
                        scmd.CommandName   = c.CommandName;
                        scmd.ATCommandText = c.ATCommandText;
                        scmd.Parameter     = Paramter.Text;

                        scmd.Msg = Msg.Text;
                        cmd      = scmd;
                    }
                    else
                    {
                        cmd               = new Command();
                        cmd.CommandName   = c.CommandName;
                        cmd.ATCommandText = c.ATCommandText;
                        cmd.Parameter     = Paramter.Text;
                        cmd.ThisType      = c.ThisType;
                        if (!string.IsNullOrEmpty(Duration.Text))
                        {
                            cmd.Duration = int.Parse(Duration.Text);
                        }
                    }

                    break;
                }
            }
            if (null != cmd)
            {
                GsmTask task = new GsmTask(taskName.Text, cmd);
                taskList.TaskLink.Add(task);
                InitControl();
                InitTv();
            }
        }
Ejemplo n.º 5
0
 public static SendSMSCommand GetSendSmsCommand()
 {
     return(SendSMSCommand.Create(GetSendSmsRequest()));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates the handler.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <returns></returns>
 private ICommandHandler CreateHandler(SendSMSCommand command)
 {
     return(new MessagingCommandHandler(this.EmailServiceProxy, this.SMSServiceProxy));
 }
        /// <summary>
        /// Handles the command.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns></returns>
        private async Task HandleCommand(SendSMSCommand command, CancellationToken cancellationToken)
        {
            var response = await this.SMSServiceProxy.SendSMS(command.SendSMSRequest, cancellationToken);

            command.Response = response;
        }