public async Task Handle(TournamentPriceChangedIntegrationEvent notification, CancellationToken cancellationToken)
        {
            var playersToInform = await _playerRepository.GetPlayersByMinimumRating(Constant.MinRatingForTournamentInforming);

            foreach (var player in playersToInform)
            {
                await _smsProvider.SendSms(player.PhoneNumber, notification.ToString());
            }
        }
        public async Task Handle(TournamentDateChangedIntegrationEvent notification, CancellationToken cancellationToken)
        {
            if (notification.PlayerList != null)
            {
                var playersToInform = await _playerRepository.GetPlayersByIdList(notification.PlayerList);

                foreach (var player in playersToInform)
                {
                    await _smsProvider.SendSms(player.PhoneNumber, notification.ToString());
                }
            }
        }
Ejemplo n.º 3
0
        public IActionResult Post([FromBody] SmsRequest smsRequest)
        {
            Log.Information($"Received sms message: {JsonSerializer.Serialize(smsRequest)} and are attempting send.");

            try
            {
                return(Ok(_smsProvider.SendSms(smsRequest)));
            }
            catch (Exception ex)
            {
                Log.Information($"Failure! Sms message: {JsonSerializer.Serialize(smsRequest)} did not send.");
                return(Ok(ex));
            }
        }
        public string SendSms(string massage, string number)
        {
            try
            {
                this.IsSuccess = true;
                return(_provider.SendSms(massage, number));
            }
            catch (Exception e)
            {
                this.Error     = e.Message;
                this.IsSuccess = false;
            }

            return(string.Empty);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Sends an sms using a provider (lox24 is default)
        /// </summary>
        /// <param name="number">Phone number</param>
        /// <param name="body">Sms text</param>
        /// <returns>True if successfull</returns>
        public bool SendSms(SmsQueue smsQueue)
        {
            var result = smsProvider.SendSms(smsQueue.Number, smsQueue.Body);

            if (result == null)
            {
                return(false);
            }

            var resultLox24 = result as Lox24Result;

            if (resultLox24 != null)
            {
                if (resultLox24.StatusCode == Lox24ResultStatus.SmsSuccess ||
                    resultLox24.StatusCode == Lox24ResultStatus.SuccessfulQuery ||
                    resultLox24.StatusCode == Lox24ResultStatus.CommandExecuted)
                {
                    smsQueue.SentTime         = DateTime.Now;
                    smsQueue.Status           = SmsStatus.Sent;
                    smsQueue.ProviderResponse = resultLox24.ResultText;

                    Save(smsQueue);

                    return(true);
                }
                else
                {
                    smsQueue.Status           = SmsStatus.Failed;
                    smsQueue.ProviderResponse = resultLox24.ResultText;

                    Save(smsQueue);

                    return(false);
                }
            }

            return(false);
        }