public async Task<SvamletModel> Post(CallbackEventModel model) {
            var sinch = SinchFactory.CreateCallbackResponseFactory(Locale.EnUs);
            var reader = sinch.CreateEventReader();
            var evt = reader.ReadModel(model);
            var builder = sinch.CreateIceSvamletBuilder();
            switch (evt.Event) {
                case Event.IncomingCall:
                    builder.AddNumberInputMenu("menu1", "Enter 4 digits", 4, "Enter 4 digits", 3, TimeSpan.FromSeconds(60));
                    builder.RunMenu("menu1");
                    break;
                case Event.PromptInput:
                    using (var db = new ConferenceContext()) {

                        var conference = db.Conferences.FirstOrDefault(c => c.PinCode == model.MenuResult.Value);
                        if (conference != null)
                        {
                            builder.ConnectConference(conference.ConferenceId.ToString());
                        } else {
                            builder.Say("Invalid code").Hangup(HangupCause.Normal);
                        }
                    }

                    break;
                case Event.AnsweredCall:
                    builder.Continue();
                    break;
                default:
                    break;
            }
            return builder.Build().Model;
        }
Пример #2
0
        public async Task<ActionResult> Details(int id) {
            var model = new ConferenceDetailsViewModel();
            //1. First fetch the conference details form the database.
            using (var db = new ConferenceContext())
            {
                var conference = db.Conferences.FirstOrDefault(c => c.Id == id);
                if (conference != null)
                    model.Conference = conference;
            }

            try
            {
                var conf = await Getconference(model.Conference.ConferenceId.ToString()).Get();
                // store the participants in the result model
                model.Participants = conf.Participants;
            }
            catch (Exception)
            {
                model.Participants = new IParticipant[0];
                //do nothing, just means no one is in the conference
            }
         
            
            return View(model);
        }
Пример #3
0
 public ActionResult Index() {
     using (var db = new ConferenceContext())
     {
         var model = db.Conferences.ToList();
         return View(model);
     }
 }
Пример #4
0
 public async Task<RedirectToRouteResult> Create(Conference model) {
     using (var db = new ConferenceContext()) {
         // lets add a new guid to the model to ensure that all conferences are uniq
         model.ConferenceId = Guid.NewGuid();
         //save it
         db.Conferences.Add(model);
         await db.SaveChangesAsync();
     }
     //return tohome controller
     return RedirectToAction("Index");
 }