예제 #1
0
        public async Task <TwilioResponse> Answer(TwilioRequest request)
        {
            await SetMemberInfoFromPhone(request.From);
            await UpdateSigninStatus();

            using (var db = dbFactory())
            {
                var call = new VoiceCall
                {
                    CallId   = request.CallSid,
                    Number   = request.From,
                    CallTime = TimeUtils.GetLocalDateTime(this.config),
                    Name     = this.session.MemberName
                };

                db.Calls.Add(call);
                await db.SaveChangesAsync();

                this.config.GetPushHub <CallsHub>().updatedCall(CallsController.GetCallEntry(call));
            }

            var response = new TwilioResponse();

            BeginMenu(response);
            if (this.session.MemberId == null)
            {
                response.SayVoice(Speeches.WelcomeUnknownCaller);
            }

            await EndMenu(response);

            return(LogResponse(response));
        }
예제 #2
0
        public async Task <TwilioResponse> StopRecording(TwilioRequest request)
        {
            TwilioResponse response = new TwilioResponse();

            using (var db = dbFactory())
            {
                var call = db.Calls.Single(f => f.CallId == request.CallSid);
                //if (!string.IsNullOrWhiteSpace(call.RecordingUrl))
                //{
                //  // Delete previous recording
                //}
                call.RecordingDuration = request.RecordingDuration;
                call.RecordingUrl      = request.RecordingUrl;
                await db.SaveChangesAsync();

                this.session.HasRecording = true;

                this.config.GetPushHub <CallsHub>().updatedCall(CallsController.GetCallEntry(call));

                BeginMenu(response);
                response.SayVoice(Speeches.CallerRecordingSaved);
                await EndMenu(response, true);
            }
            return(LogResponse(response));
        }
예제 #3
0
        public async Task <TwilioResponse> Complete(TwilioRequest request)
        {
            using (var db = dbFactory())
            {
                var call = db.Calls.Where(f => f.CallId == request.CallSid).SingleOrDefault();
                if (call != null)
                {
                    call.Duration = request.CallDuration;
                    await db.SaveChangesAsync();

                    this.config.GetPushHub <CallsHub>().updatedCall(CallsController.GetCallEntry(call));
                }
            };

            var response = new TwilioResponse();

            response.Hangup();
            return(LogResponse(response));
        }