public ActionResult Number(Reservation model) { _log.InfoFormat("New request number: {0} attempting entry.", model.Number); if (!NumberValidator.IsPhoneNumber(model.Number)) { return(View()); } if (_twilioRepository.MaxRequestsNotReached(model.Number) && _personRepository.CheckPhoneNumberExists(model.Number)) { TwilioMessage message = new TwilioMessage() { To = model.Number, Message = _codeGenerator.GenerateCode() }; //Send Message to Phone Number _twilioMessageProvider.SendMessage(message); //Create the database object TwilioMessaging messageDB = new TwilioMessaging() { Code = _codeGenerator.HashCode(message.Message), Date = DateTime.Now, PhoneNumber = model.Number }; //Log code _twilioRepository.AddRequest(messageDB); } return(View()); }
public HttpResponseMessage SendMessage(TwilioMessaging model) { try { model.MessageBody = "Message from VetChat" + Environment.NewLine + Environment.NewLine + model.MessageBody + Environment.NewLine + Environment.NewLine + model.MyPhone + Environment.NewLine + Environment.NewLine + model.Signature; TwilioService.SendMessage(model.PhoneNumberTo, model.MessageBody); SuccessResponse response = new SuccessResponse(); return(Request.CreateResponse(response)); } catch (Exception ex) { var response = new ErrorResponse(ex.Message); return(Request.CreateResponse(response)); } }
// Use this for initialization void Start() { this.emailsent = false; this.started = false; this.numViolations = 0; this.canSMS = true; this.decibels = new List<DecibelEvent> (); this.twilio = this.GetComponent<TwilioMessaging> (); this.sendgrid = this.GetComponent<SG_Email> (); this.GetComponent<DecibelReader> ().setOnDecibel (this.OnDecibel); this.loadSaved (); }
void Start () { twilio = GetComponent<TwilioMessaging>(); }