public ActionResult VoiceMessage(int eventCode, string toDial) { if (!String.IsNullOrWhiteSpace(toDial)) { return(VoiceMessageDial("", toDial)); } Event e; using (var service = new EventService()) { e = service.Get(eventCode); } if (e == null) { throw new ArgumentException("Invalid event code: " + eventCode); } MessageTemplateType templateType = EventProcessingService.GetTemplateType(e); List <TwilioGatherOption> options = TwilioService.GetGatherOptions(templateType); if (options.Count > 0) { return(VoiceMessageGather(e.Message, options)); } return(VoiceMessageSay(null, e.Message)); }
public ActionResult VoiceMessageGathered(string Digits) { string fromNumber = Request.Params["From"]; string callSid = Request.Params["CallSid"]; bool isActionFound = false; object response = null; Event eventObj = EventProcessingService.GetEvent(callSid); MessageTemplateType templateType = EventProcessingService.GetTemplateType(eventObj); List <TwilioGatherOption> optRedirects = TwilioService.GetGatherOptions(templateType); foreach (var opt in optRedirects) { if (opt.Digits.Equals(Digits)) { response = EventProcessingService.HandleResponse(opt.ResponseOption, eventObj); isActionFound = true; } } if (!isActionFound) { response = new TwilioDialModel() { MessageBody = "An application error has occurred. You are being redirected to your pharmacy for assistance.", DialTo = new PhoneNumber(eventObj.Patient.Pharmacy.Phone) }; } if (response is TwilioDialModel) { TwilioDialModel tdm = (TwilioDialModel)response; return(RedirectToAction("VoiceMessageDial", new { toSay = tdm.MessageBody, toDial = tdm.DialTo })); } if (response is ActionResult) { return((ActionResult)response); } return(RedirectToAction("VoiceMessageSay", new { toSay = response.ToString() })); }