コード例 #1
0
ファイル: TestModule.cs プロジェクト: seun104/AgbaraVOIP
        public TestModule(IInboundDependency apiServer)
            : base("/test")
        {
            this.apiserver = apiServer;
            this.RequiresAuthentication();

            Post["/Call"] = x =>
            {

                    var request = this.Bind<CallRequest>();
                    request.AccountSid = Context.CurrentUser.UserName;
                    Call res = apiserver.GetServer().Call(request);
                    return Response.AsXml<Call>(res);
            };
            Post["/Call.json"] = x =>
            {

                var request = this.Bind<CallRequest>();
                request.AccountSid = Context.CurrentUser.UserName;
                Call res = apiserver.GetServer().Call(request);
                return Response.AsJson<Call>(res);
            };

            Get["/Call"] = x =>
            {

                var request = this.Bind<CallRequest>();
                request.AccountSid = Context.CurrentUser.UserName;
                Call res = apiserver.GetServer().Call(request);
                return Response.AsXml<Call>(res);
            };
        }
コード例 #2
0
ファイル: TestModule.cs プロジェクト: lichien2017/AgbaraVOIP
        public TestModule(IInboundDependency apiServer)
            : base("/test")
        {
            this.apiserver = apiServer;
            this.RequiresAuthentication();

            Post["/Call"] = x =>
            {
                var request = this.Bind <CallRequest>();
                request.AccountSid = Context.CurrentUser.UserName;
                Call res = apiserver.GetServer().Call(request);
                return(Response.AsXml <Call>(res));
            };
            Post["/Call.json"] = x =>
            {
                var request = this.Bind <CallRequest>();
                request.AccountSid = Context.CurrentUser.UserName;
                Call res = apiserver.GetServer().Call(request);
                return(Response.AsJson <Call>(res));
            };

            Get["/Call"] = x =>
            {
                var request = this.Bind <CallRequest>();
                request.AccountSid = Context.CurrentUser.UserName;
                Call res = apiserver.GetServer().Call(request);
                return(Response.AsXml <Call>(res));
            };
        }
コード例 #3
0
        public CallModule(IInboundDependency apiServer)
        {
            this.apiserver   = apiServer;
            this.callService = new CallService();
            this.RequiresAuthentication();

            #region Get All Calls
            Get["/Accounts/{AccountSid}/Calls"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                return(Response.AsXml <IEnumerable <Call> >(callService.GetAllCalls(Context.CurrentUser.UserName)));
            };
            #endregion

            #region Make Call
            Post["/Accounts/{AccountSid}/Calls/Call.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                var request = this.Bind <CallRequest>();
                //Todo
                //Validation
                request.AccountSid = Context.CurrentUser.UserName;
                Call res = apiserver.GetServer().Call(request);
                return(Response.AsJson <Call>(res));
            };
            Post["/Accounts/{AccountSid}/Calls/Call"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                var request = this.Bind <CallRequest>();
                request.AccountSid = Context.CurrentUser.UserName;
                Call res = apiserver.GetServer().Call(request);
                return(Response.AsXml <Call>(res));
            };
            #endregion

            #region Modify Call
            Post["/Accounts/{AccountSid}/Calls/{CallSid}.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }

                var request = this.Bind <CallRequest>();
                request.AccountSid = Context.CurrentUser.UserName;
                Call res = apiserver.GetServer().Call(request);
                return(Response.AsJson <Call>(res));
            };
            Post["/Accounts/{AccountSid}/Calls/{CallSid}"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                var request = this.Bind <CallRequest>();
                request.AccountSid = Context.CurrentUser.UserName;
                Call res = apiserver.GetServer().Call(request);
                return(Response.AsXml <Call>(res));
            };
            #endregion

            #region Play to Call
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Play.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var request = this.Bind <CallPlayRequest>();
                    request.AccountSid = Context.CurrentUser.UserName;
                    request.CallSid    = x.CallSid;
                    CallPlayResponse res = apiserver.GetServer().CallPlay(request);
                    return(Response.AsJson <CallPlayResponse>(res));
                }
            };
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Play"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var request = this.Bind <CallPlayRequest>();
                    request.CallSid    = x.CallSid;
                    request.AccountSid = Context.CurrentUser.UserName;
                    CallPlayResponse res = apiserver.GetServer().CallPlay(request);
                    return(Response.AsXml <CallPlayResponse>(res));
                }
            };
            #endregion

            #region Stop Call Play
            Delete["/Accounts/{AccountSid}/Calls/{CallSid}/Play"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    if (apiserver.GetServer().StopCallPlay(x.CallSid))
                    {
                        return(HttpStatusCode.NoContent);
                    }
                    else
                    {
                        return(HttpStatusCode.NoResponse);
                    }
                    //else to do
                }
            };
            #endregion

            #region Record Call
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Record.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var request = this.Bind <CallRecordRequest>();
                    request.AccountSid = Context.CurrentUser.UserName;
                    CallRecordResponse res = apiserver.GetServer().CallRecord(request);
                    return(Response.AsJson <CallRecordResponse>(res));
                }
            };
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Record"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var request = this.Bind <CallRecordRequest>();
                    request.AccountSid = Context.CurrentUser.UserName;
                    CallRecordResponse res = apiserver.GetServer().CallRecord(request);
                    return(Response.AsXml <CallRecordResponse>(res));
                }
            };
            #endregion

            #region Stop Call Record
            Delete["/Accounts/{AccountSid}/Calls/{CallSid}/Record"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    if (apiserver.GetServer().StopCallRecord(x.CallSid))
                    {
                        return(HttpStatusCode.NoContent);
                    }
                    else
                    {
                        return(HttpStatusCode.NoResponse);
                    }
                }
            };
            #endregion

            #region Speak
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Speak.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var request = this.Bind <CallSpeakRequest>();
                    request.AccountSid = Context.CurrentUser.UserName;
                    CallSpeakResponse res = apiserver.GetServer().CallSpeak(request);
                    return(Response.AsJson <CallSpeakResponse>(res));
                }
            };
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Speak"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var request = this.Bind <CallSpeakRequest>();
                    request.AccountSid = Context.CurrentUser.UserName;
                    CallSpeakResponse res = apiserver.GetServer().CallSpeak(request);
                    return(Response.AsXml <CallSpeakResponse>(res));
                }
            };
            #endregion

            #region Digits
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Digit.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var request = this.Bind <CallDigitRequest>();
                    request.AccountSid = Context.CurrentUser.UserName;
                    CallDigitResponse res = apiserver.GetServer().CallDigit(request);
                    return(Response.AsJson <CallDigitResponse>(res));
                }
            };
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Digit"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var request = this.Bind <CallDigitRequest>();
                    request.AccountSid = Context.CurrentUser.UserName;
                    CallDigitResponse res = apiserver.GetServer().CallDigit(request);
                    return(Response.AsXml <CallDigitResponse>(res));
                }
            };
            #endregion
        }
コード例 #4
0
ファイル: CallModule.cs プロジェクト: seun104/AgbaraVOIP
        public CallModule(IInboundDependency apiServer)
        {
            this.apiserver = apiServer;
            this.callService = new CallService();
            this.RequiresAuthentication();

            #region Get All Calls
            Get["/Accounts/{AccountSid}/Calls"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                { return HttpStatusCode.Unauthorized; }
                return Response.AsXml<IEnumerable<Call>>(callService.GetAllCalls(Context.CurrentUser.UserName));
            };
            #endregion

            #region Make Call
            Post["/Accounts/{AccountSid}/Calls/Call.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                { return HttpStatusCode.Unauthorized; }
                var request = this.Bind<CallRequest>();
                //Todo
                //Validation
                request.AccountSid = Context.CurrentUser.UserName;
                Call res = apiserver.GetServer().Call(request);
                return Response.AsJson<Call>(res);
            };
            Post["/Accounts/{AccountSid}/Calls/Call"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                { return HttpStatusCode.Unauthorized; }
                var request = this.Bind<CallRequest>();
                request.AccountSid = Context.CurrentUser.UserName;
                Call res = apiserver.GetServer().Call(request);
                return Response.AsXml<Call>(res);
            };
            #endregion

            #region Modify Call
            Post["/Accounts/{AccountSid}/Calls/{CallSid}.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                { return HttpStatusCode.Unauthorized; }

                var request = this.Bind<CallRequest>();
                request.AccountSid = Context.CurrentUser.UserName;
                Call res = apiserver.GetServer().Call(request);
                return Response.AsJson<Call>(res);
            };
            Post["/Accounts/{AccountSid}/Calls/{CallSid}"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                { return HttpStatusCode.Unauthorized; }
                var request = this.Bind<CallRequest>();
                request.AccountSid = Context.CurrentUser.UserName;
                Call res = apiserver.GetServer().Call(request);
                return Response.AsXml<Call>(res);
            };
            #endregion

            #region Play to Call
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Play.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                { return HttpStatusCode.Unauthorized; }
                else
                {
                    var request = this.Bind<CallPlayRequest>();
                    request.AccountSid = Context.CurrentUser.UserName;
                    request.CallSid = x.CallSid;
                    CallPlayResponse res = apiserver.GetServer().CallPlay(request);
                    return Response.AsJson<CallPlayResponse>(res);
                }
            };
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Play"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                { return HttpStatusCode.Unauthorized; }
                else
                {
                    var request = this.Bind<CallPlayRequest>();
                    request.CallSid = x.CallSid;
                    request.AccountSid = Context.CurrentUser.UserName;
                    CallPlayResponse res = apiserver.GetServer().CallPlay(request);
                    return Response.AsXml<CallPlayResponse>(res);
                }
            };
            #endregion

            #region Stop Call Play
            Delete["/Accounts/{AccountSid}/Calls/{CallSid}/Play"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                { return HttpStatusCode.Unauthorized; }
                else
                {
                    if (apiserver.GetServer().StopCallPlay(x.CallSid))
                    { return HttpStatusCode.NoContent; }
                    else { return HttpStatusCode.NoResponse; }
                    //else to do
                }
            };
            #endregion

            #region Record Call
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Record.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                { return HttpStatusCode.Unauthorized; }
                else
                {
                    var request = this.Bind<CallRecordRequest>();
                    request.AccountSid = Context.CurrentUser.UserName;
                    CallRecordResponse res = apiserver.GetServer().CallRecord(request);
                    return Response.AsJson<CallRecordResponse>(res);
                }
            };
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Record"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                { return HttpStatusCode.Unauthorized; }
                else
                {
                    var request = this.Bind<CallRecordRequest>();
                    request.AccountSid = Context.CurrentUser.UserName;
                    CallRecordResponse res = apiserver.GetServer().CallRecord(request);
                    return Response.AsXml<CallRecordResponse>(res);
                }
            };
            #endregion

            #region Stop Call Record
            Delete["/Accounts/{AccountSid}/Calls/{CallSid}/Record"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                { return HttpStatusCode.Unauthorized; }
                else
                {
                    if (apiserver.GetServer().StopCallRecord(x.CallSid))
                    { return HttpStatusCode.NoContent; }
                    else { return HttpStatusCode.NoResponse; }
                }
            };
            #endregion

            #region Speak
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Speak.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                { return HttpStatusCode.Unauthorized; }
                else
                {
                    var request = this.Bind<CallSpeakRequest>();
                    request.AccountSid = Context.CurrentUser.UserName;
                    CallSpeakResponse res = apiserver.GetServer().CallSpeak(request);
                    return Response.AsJson<CallSpeakResponse>(res);
                }
            };
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Speak"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                { return HttpStatusCode.Unauthorized; }
                else
                {
                    var request = this.Bind<CallSpeakRequest>();
                    request.AccountSid = Context.CurrentUser.UserName;
                    CallSpeakResponse res = apiserver.GetServer().CallSpeak(request);
                    return Response.AsXml<CallSpeakResponse>(res);
                }
            };
            #endregion

            #region Digits
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Digit.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                { return HttpStatusCode.Unauthorized; }
                else
                {
                    var request = this.Bind<CallDigitRequest>();
                    request.AccountSid = Context.CurrentUser.UserName;
                    CallDigitResponse res = apiserver.GetServer().CallDigit(request);
                    return Response.AsJson<CallDigitResponse>(res);
                }
            };
            Post["/Accounts/{AccountSid}/Calls/{CallSid}/Digit"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                { return HttpStatusCode.Unauthorized; }
                else
                {
                    var request = this.Bind<CallDigitRequest>();
                    request.AccountSid = Context.CurrentUser.UserName;
                    CallDigitResponse res = apiserver.GetServer().CallDigit(request);
                    return Response.AsXml<CallDigitResponse>(res);
                }
            };
            #endregion
        }
コード例 #5
0
        public ConferenceModule(IInboundDependency apiServe)
        {
            this.RequiresAuthentication();
            this.confService = new ConferenceService();

            #region Get All Conferences
            Get["/Accounts/{AccountSid}/Conferences"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var AccountSid = Context.CurrentUser.UserName;
                    IQueryable <Conference> res = confService.GetAllConferences(AccountSid);
                    return(Response.AsXml <IQueryable <Conference> >(res));
                }
            };
            Get["/Accounts/{AccountSid}/Conferences.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var AccountSid = Context.CurrentUser.UserName;
                    IQueryable <Conference> res = confService.GetAllConferences(AccountSid);
                    return(Response.AsJson <IQueryable <Conference> >(res));
                }
            };
            #endregion

            #region Get Conference
            Get["/Accounts/{AccountSid}/Conferences/{ConferenceSid}"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    Conference res = confService.GetConference(x.ConferenceSid);
                    return(Response.AsXml <Conference>(res));
                }
            };

            Get["/Accounts/{AccountSid}/Conferences/{ConferenceSid}.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    Conference res = confService.GetConference(x.ConferenceSid);
                    return(Response.AsJson <Conference>(res));
                }
            };
            #endregion

            #region Get All Conference Participants
            Get["/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var AccountSid               = Context.CurrentUser.UserName;
                    var ConferenceSid            = x.ConfenrenceSid;
                    IQueryable <Participant> res = confService.GetAllConferenceParticipants(AccountSid, ConferenceSid);
                    return(Response.AsXml <IQueryable <Participant> >(res));
                }
            };
            Get["/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var AccountSid               = Context.CurrentUser.UserName;
                    var ConferenceSid            = x.ConfenrenceSid;
                    IQueryable <Participant> res = confService.GetAllConferenceParticipants(AccountSid, ConferenceSid);
                    return(Response.AsJson <IQueryable <Participant> >(res));
                }
            };
            #endregion

            #region Get Participant
            Get["/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    Participant res = confService.GetParticipant(x.ConferenceSid, x.CallSid);
                    return(Response.AsXml <Participant>(res));
                }
            };

            Get["/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    Participant res = confService.GetParticipant(x.ConferenceSid, x.CallSid);
                    return(Response.AsJson <Participant>(res));
                }
            };
            #endregion

            #region Mute/Unmute Participant
            Post["/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var request = this.Bind <MuteParticipantRequest>();
                    //Todo
                    //Validation
                    MuteParticipantResponse res = apiserver.GetServer().ConferenceMuteParticipant(request);
                    return(Response.AsXml <MuteParticipantResponse>(res));
                }
            };

            Post["/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var request = this.Bind <MuteParticipantRequest>();
                    //Todo
                    //Validation
                    MuteParticipantResponse res = apiserver.GetServer().ConferenceMuteParticipant(request);
                    return(Response.AsJson <MuteParticipantResponse>(res));
                }
            };
            #endregion

            #region Kick Participant
            Delete["/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    if (apiserver.GetServer().ConferenceKickParticipant(x.ConferenceSid, x.CallSid))
                    {
                        return(HttpStatusCode.NoContent);
                    }
                    else
                    {
                        return(HttpStatusCode.NoResponse);
                    }
                }
            };
            #endregion

            #region Record Conference
            Post["/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Record"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var request = this.Bind <ConferenceRecordRequest>();
                    //Todo
                    //Validation
                    ConferenceRecordResponse res = apiserver.GetServer().ConferenceRecord(request);
                    return(Response.AsXml <ConferenceRecordResponse>(res));
                }
            };

            Post["/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Record.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var request = this.Bind <ConferenceRecordRequest>();
                    //Todo
                    //Validation
                    ConferenceRecordResponse res = apiserver.GetServer().ConferenceRecord(request);
                    return(Response.AsJson <ConferenceRecordResponse>(res));
                }
            };
            #endregion

            #region Stop Record Conference
            Delete["/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Record"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    if (x.AccountSid != Context.CurrentUser.UserName)
                    {
                        return(HttpStatusCode.Unauthorized);
                    }
                    else
                    {
                        if (apiserver.GetServer().ConferenceStopRecord(x.ConferenceSid))
                        {
                            return(HttpStatusCode.NoContent);
                        }
                        else
                        {
                            return(HttpStatusCode.NoResponse);
                        }
                    }
                }
            };
            #endregion

            #region Conference Play
            Post["/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Play"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var request = this.Bind <ConferencePlayRequest>();
                    //Todo
                    //Validation
                    ConferencePlayResponse res = apiserver.GetServer().ConferencePlay(request);
                    return(Response.AsXml <ConferencePlayResponse>(res));
                }
            };

            Post["/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Play.json"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    var request = this.Bind <ConferencePlayRequest>();
                    //Todo
                    //Validation
                    ConferencePlayResponse res = apiserver.GetServer().ConferencePlay(request);
                    return(Response.AsJson <ConferencePlayResponse>(res));
                }
            };
            #endregion

            #region Conference Stop Play
            Delete["/Accounts/{AccountSid}/Conferences/{ConferenceSid}/Play"] = x =>
            {
                if (x.AccountSid != Context.CurrentUser.UserName)
                {
                    return(HttpStatusCode.Unauthorized);
                }
                else
                {
                    if (x.AccountSid != Context.CurrentUser.UserName)
                    {
                        return(HttpStatusCode.Unauthorized);
                    }
                    else
                    {
                        if (apiserver.GetServer().ConferenceStopCall(x.ConferenceSid))
                        {
                            return(HttpStatusCode.NoContent);
                        }
                        else
                        {
                            return(HttpStatusCode.NoResponse);
                        }
                    }
                }
            };
            #endregion
        }