Exemplo n.º 1
0
        private static void Main()
        {
            var repositoryConfig = new RepositoryConfiguration
            {
                ConnectionString = AppSettingHelper.GetDbConnection()
            };

            var persistenceFactory = new VakapayRepositoryMysqlPersistenceFactory(repositoryConfig);
            var sendSmsBusiness    = new SendSmsBusiness.SendSmsBusiness(persistenceFactory);

            while (true)
            {
                try
                {
                    var result = sendSmsBusiness.SendSmsAsync(AppSettingHelper.GetElasticSmsUrl(),
                                                              AppSettingHelper.GetElasticApiKey());
                    Console.WriteLine(JsonHelper.SerializeObject(result.Result));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }

                Thread.Sleep(1000);
            }
        }
Exemplo n.º 2
0
        // Send code when do action
        public ReturnObject SendSms(User user, string code)
        {
            try
            {
                var sendSmsRepository = new SendSmsBusiness.SendSmsBusiness(_vakapayRepositoryFactory, false);

                var newSms = new SmsQueue
                {
                    Status   = Status.STATUS_PENDING,
                    To       = user.PhoneNumber,
                    TextSend = "VaKaXaPay security code is: " + code,
                };

                var resultSms = sendSmsRepository.CreateSmsQueueAsync(newSms);

                if (resultSms.Status == Status.STATUS_ERROR)
                {
                    return(new ReturnObject
                    {
                        Status = Status.STATUS_ERROR,
                        Message = "Fail insert to sendSms " + resultSms.Message
                    });
                }


                return(new ReturnObject
                {
                    Status = Status.STATUS_SUCCESS,
                    Message = "Success"
                });
            }
            catch (Exception e)
            {
                return(new ReturnObject
                {
                    Status = Status.STATUS_ERROR,
                    Message = e.Message
                });
            }
        }