public virtual ActionResult Category(string slug, int page = 1, string parentSlug = null) { CategoryModel category; try { category = _blogRepository.GetCategory(slug); } catch (EntityNotFoundException) { // Throw a 404 if the category doesn't exist return(HttpNotFound(string.Format("Category '{0}' not found.", slug))); } // If the category has a parent category, ensure it's in the URL if (!string.IsNullOrEmpty(category.ParentSlug) && string.IsNullOrEmpty(parentSlug)) { return(RedirectPermanent(Url.BlogCategory(category, page))); } var count = _blogRepository.PublishedCount(category); var posts = _blogRepository.LatestPosts(category, ITEMS_PER_PAGE, (page - 1) * ITEMS_PER_PAGE); return(Listing(posts, count, page, Views.Category, new CategoryListingViewModel { Category = category, RssUrl = Url.ActionAbsolute(MVC.Feed.BlogCategory(category.Slug, category.ParentSlug)) })); }
public virtual ActionResult Donate(DonateModel model) { if (!StringExtensions.IsValidLtPersonCode(model.PersonCode)) { ModelState.AddModelError("PersonCode", "Neteisingas asmens kodas"); } if (model.IsPersonCodeRequired && string.IsNullOrEmpty(model.PersonCode)) { ModelState.AddModelError("PersonCode", "Įveskite asmens kodą"); } if (ModelState.IsValid) { var result = Service.GetWebToPayModel( model, ConfigurationManager.AppSettings["WebToPay_Password"], ConfigurationManager.AppSettings["WebToPay_ProjectId"], Url.ActionAbsolute(MVC.Sponsor.Accept()), Url.ActionAbsolute(MVC.Sponsor.Cancel()), Url.ActionAbsolute(MVC.Sponsor.Callback()), ConfigurationManager.AppSettings["WebToPay_PayText"], ConfigurationManager.AppSettings["WebToPay_Test"]); if (!string.IsNullOrEmpty(model.PersonCode)) { Service.SavePersonCode(model.PersonCode); } return(View(result)); } return(View(MVC.Sponsor.Views.About, model)); }
public ActionResult LeaveGameExperience() { var response = new TwilioResponse(); response.Say("Thanks for playing a game."); response.Redirect(Url.ActionAbsolute("BasicWaitExperience")); return(TwiML(response)); }
public ActionResult Introduction(string CallSid) { var quizShow = QuizShowState.CreateAndSave(CallSid); var response = new TwilioResponse(); response.Say("Welcome to the Twilio Quiz Show! Playing the game is simple. Just answer 5 trivia questions."); response.Say("Are you ready? . "); response.Redirect(Url.ActionAbsolute("ReadQuestion"), "GET"); return(TwiML(response)); }
public ActionResult PlaceInConference(bool mute) { Debug.WriteLine("Putting caller into conference: {0}", mute); var response = new TwilioResponse(); response.DialConference("Chapter18Conference", new { muted = mute, beep = false, startConferenceOnEnter = true, endConferenceOnExit = false }, new { hangupOnStar = true }); response.BeginGather(new { action = Url.ActionAbsolute("ProcessCommand"), numDigits = "1" }); response.EndGather(); response.Say("Bye"); return(TwiML(response)); }
public ActionResult CaptureAnswer(string CallSid, int Digits) { var gameState = QuizShowState.Load(CallSid); var currentQuestion = gameState.Questions[gameState.CurrentQuestionIndex]; var orderedAnswers = currentQuestion.PossibleAnswers.OrderBy(a => a.Order).ToList(); var selectedAnswer = orderedAnswers[Digits]; var response = new TwilioResponse(); if (selectedAnswer.IsCorrect) { gameState.CorrectAnswerCount++; response.Say("Correct! . Well done. "); if (gameState.CurrentQuestionIndex >= 4) { response.Say("That was the last question. Lets see how you did."); response.Redirect(Url.ActionAbsolute("CalculateResults"), "GET"); } else { gameState.CurrentQuestionIndex++; response.Say("Lets try the next question."); response.Redirect(Url.ActionAbsolute("ReadQuestion"), "GET"); } } else { response.Say("Incorrect! . "); if (gameState.CurrentQuestionIndex >= 4) { response.Say("That was the last question. Lets see how you did."); response.Redirect(Url.ActionAbsolute("CalculateResults"), "GET"); } else { gameState.CurrentQuestionIndex++; response.Say("Lets try the next question."); response.Redirect(Url.ActionAbsolute("ReadQuestion"), "GET"); } } gameState.Save(); return(TwiML(response)); }
public ActionResult EnqueueCaller(string callsid) { QueueState.CreateAndSave(callsid); var response = new TwilioResponse(); response.Say("Adding you to the queue"); response.Enqueue("CustomerServiceQueue", new { action = Url.ActionAbsolute("LeaveQueue"), waitUrl = Url.ActionAbsolute("DetermineWaitExperience") }); return(TwiML(response)); }
private void CreateTrigger() { var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken); var trigger = client.CreateUsageTrigger(new UsageTriggerOptions() { UsageCategory = "sms-inbound", FriendlyName = "Chapter13Trigger", TriggerBy = "usage", TriggerValue = "+3", CallbackUrl = Url.ActionAbsolute("TriggerCallbackHandler") }); if (trigger.RestException != null) { Console.WriteLine(trigger.RestException.Message); } }
public virtual ActionResult BlogLatest() { if (Request.ShouldRedirectToFeedburner()) { return(Redirect(_siteConfig.FeedBurnerUrl.ToString())); } var posts = _blogRepository.LatestPosts(ITEMS_IN_FEED); return(RenderFeed(posts, new FeedViewModel { FeedGuidBase = "Latest", Title = _siteConfig.BlogName, Description = _siteConfig.BlogDescription, FeedUrl = _siteConfig.FeedBurnerUrl.ToString(), SiteUrl = Url.ActionAbsolute(MVC.Blog.Index()) })); }
public ActionResult PlayInvitation(string CallSid) { var response = new TwilioResponse(); response.BeginGather( new { action = Url.ActionAbsolute("PlayInvitation"), method = "POST", numDigits = "1", timeout = "3" }); response.Say("Lets play a game while you wait."); response.Say("If you would rather just listen to music, press 1"); response.EndGather(); response.Redirect(Url.ActionAbsolute("Introduction"), "GET"); return(TwiML(response)); }
public virtual ActionResult Urls(int postId) { PostModel post; try { post = _blogRepository.Get(postId); } catch (EntityNotFoundException) { // Throw a 404 if the post doesn't exist return(HttpNotFound(string.Format("Blog post #{0} not found.", postId))); } return(Json(new { Url = Url.BlogPostAbsolute(post), ShortUrl = Url.ActionAbsolute(MVC.Blog.ShortUrl(_urlShortener.Shorten(post))) }, JsonRequestBehavior.AllowGet)); }
public ActionResult ReadQuestion(string CallSid) { var gameState = QuizShowState.Load(CallSid); var currentQuestion = gameState.Questions[gameState.CurrentQuestionIndex]; var response = new TwilioResponse(); response.Say(". OK. Here is question number " + (gameState.CurrentQuestionIndex + 1).ToString() + ". ."); response.BeginGather( new { action = Url.ActionAbsolute("CaptureAnswer"), method = "POST", numDigits = "1", timeout = "5" }); response.Say(string.Format("{0}? . . ", currentQuestion.Text)); response.Say("Is the answer. . "); var orderedAnswers = currentQuestion.PossibleAnswers.OrderBy(a => a.Order).ToList(); for (int i = 0; i < orderedAnswers.Count(); i++) { if (i == (orderedAnswers.Count() - 1)) { response.Say(string.Format("Or. {0}. {1}. . ", (i + 1).ToString(), orderedAnswers[i].Text)); } else { response.Say(string.Format(". {0}. {1}. . ", (i + 1).ToString(), orderedAnswers[i].Text)); } } response.EndGather(); response.Redirect(Url.ActionAbsolute("NoAnswerProvided"), "GET"); gameState.Save(); return(TwiML(response)); }
public ActionResult NoAnswerProvided(string CallSid) { var gameState = QuizShowState.Load(CallSid); var response = new TwilioResponse(); if (gameState.CurrentQuestionIndex >= 4) { response.Say("I didn't hear your answer in time. That was the last question. Lets see how you did."); response.Redirect(Url.ActionAbsolute("CalculateResults"), "GET"); } else { gameState.CurrentQuestionIndex++; response.Say("I didn't hear your answer in time. Lets try the next question."); response.Redirect(Url.ActionAbsolute("ReadQuestion"), "GET"); } gameState.Save(); return(TwiML(response)); }
public ActionResult CalculateResults(string CallSid) { var gameState = QuizShowState.Load(CallSid); var response = new TwilioResponse(); switch (gameState.CorrectAnswerCount) { case 0: response.Say("Woah. You got every question wrong. Maybe trivia is not for you."); break; case 1: response.Say("You got one out of five right. "); break; case 2: response.Say("Better luck next time. You answered two out of five correctly."); break; case 3: response.Say("Not bad. You answered three out of five correctly. Thats pretty average."); break; case 4: response.Say("Well done! Four out of five correct is excellent."); break; case 5: response.Say("Amazing! You got all five questions right. Your brain must be huge!"); break; } response.Redirect(Url.ActionAbsolute("DetermineWaitExperience", "Phone"), "GET"); return(TwiML(response)); }
public async Task <ActionResult> HandleCustomerCall(string CallSid, string From) { var response = new TwilioResponse(); //check the caller ID and try to find a call config that matches it IMobileServiceTable <WarmCall> warmCallTable = MobileService.GetTable <WarmCall>(); var warmCalls = await warmCallTable.ReadAsync <WarmCall>(warmCallTable.Where(w => w.CustomerPhone == From)); var warmCall = warmCalls.FirstOrDefault(); if (warmCall != null) { //update with the call sid warmCall.CustomerCallSid = CallSid; await warmCallTable.UpdateAsync(warmCall); //put the customer into a conference response.Say("Please while while we conjure a support agent"); response.DialConference(CallSid); //dial an agent var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken); var result = client.InitiateOutboundCall("+17862200728", warmCall.AgentOnePhone, Url.ActionAbsolute("HandleAgentOneCall")); if (result.RestException != null) { Console.WriteLine(result.RestException.Message); } //let the browser know that the customer has connected and we're calling the agent } else { response.Say("Who are you? Go away!"); response.Hangup(); } return(TwiML(response)); }
public async Task <ActionResult> ConnectAgentTwo(string To) { //check the caller ID and try to find a call config that matches it IMobileServiceTable <WarmCall> warmCallTable = MobileService.GetTable <WarmCall>(); var warmCalls = await warmCallTable.ReadAsync <WarmCall>(warmCallTable.Where(w => w.AgentTwoPhone == To)); var warmCall = warmCalls.FirstOrDefault(); if (warmCall != null) { var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken); var result = client.InitiateOutboundCall("+17862200728", warmCall.AgentTwoPhone, Url.ActionAbsolute("HandleAgentTwoCall")); if (result.RestException != null) { Console.WriteLine(result.RestException.Message); } } return(new EmptyResult()); }