public async Task <SmsSenderResult> SendSmsAsync(SendSmsRequestModel model)
        {
            var isSuccessful = await _smsService.CreateAsync(model.MessageId, model.PhoneNumber, model.Message);

            var result = new SmsSenderResult {
                Result = SmsResult.Ok
            };

            if (isSuccessful)
            {
                return(result);
            }

            result.Result       = SmsResult.Error;
            result.ErrorMessage = "Error saving to database";

            return(result);
        }
Exemplo n.º 2
0
        public async virtual Task <SendSmsResponse> SendMessageAsync(SendSmsRequest message)
        {
            var request = new RestRequest("services/send-sms", Method.POST);

            var requestModel = new SendSmsRequestModel(new SendSmsRequestPayload(message));

            requestModel.Bind(request);

            var s = Serializer.Serialize(requestModel.Data);

            var response = await RestClient.ExecuteTaskAsync <SendSmsResponsePayload>(request);

            if (!response.IsSuccessful)
            {
                ThrowResponseException(response);
            }

            return(response.Data?.SendSmsResponse);
        }
Exemplo n.º 3
0
        public IHttpActionResult SendSMSXml([FromUri] SendSmsRequestModel model)
        {
            if (ModelState.IsValid)
            {
                var result = SendSMS(model.from, model.to, model.text);

                if (result == Status.Success)
                {
                    return(Content(HttpStatusCode.OK, "Sucess", Configuration.Formatters.XmlFormatter));
                }
                else
                {
                    return(Content(HttpStatusCode.NotFound, "Failed: Sms could not be sent to phone number: " + model.to, Configuration.Formatters.XmlFormatter));
                }
            }
            else
            {
                return(BadRequest("Invalid data: (tip): include %2B (= symbol (+)) in the beginning of the number"));
            }
        }
Exemplo n.º 4
0
 public async Task <SmsSenderResult> SendSmsAsync(SendSmsRequestModel model)
 {
     return(await _smsService.SendSmsAsync(model));
 }