internal IReservation CreateReservation(string id, double payment, double downpayment, ReservationStatus rstatus) { connect(); SQLiteCommand cmd = new SQLiteCommand("INSERT INTO Reservation VALUES (@RESERVATIONID,@PAYMENT,@DOWNPAYMENT,@RSTATUS)", sqlCon); cmd.Parameters.AddWithValue("@RESERVATIONID", id); cmd.Parameters.AddWithValue("@PAYMENT", payment); cmd.Parameters.AddWithValue("@DOWNPAYMENT", downpayment); cmd.Parameters.AddWithValue("@RSTATUS", rstatus.ToString()); try { cmd.ExecuteNonQuery(); id = cmd.Parameters["@RESERVATIONID"].Value.ToString(); } catch (Exception ex) { throw new Exception("Could not add reservation to database!\n" + ex.Message); } finally { disconnect(); } return(GetReservation(id)); }
/// <summary> /// Generate the necessary parameters /// </summary> public List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (ReservationStatus != null) { p.Add(new KeyValuePair <string, string>("ReservationStatus", ReservationStatus.ToString())); } if (WorkerActivitySid != null) { p.Add(new KeyValuePair <string, string>("WorkerActivitySid", WorkerActivitySid.ToString())); } if (Instruction != null) { p.Add(new KeyValuePair <string, string>("Instruction", Instruction)); } if (DequeuePostWorkActivitySid != null) { p.Add(new KeyValuePair <string, string>("DequeuePostWorkActivitySid", DequeuePostWorkActivitySid.ToString())); } if (DequeueFrom != null) { p.Add(new KeyValuePair <string, string>("DequeueFrom", DequeueFrom)); } if (DequeueRecord != null) { p.Add(new KeyValuePair <string, string>("DequeueRecord", DequeueRecord)); } if (DequeueTimeout != null) { p.Add(new KeyValuePair <string, string>("DequeueTimeout", DequeueTimeout.Value.ToString())); } if (DequeueTo != null) { p.Add(new KeyValuePair <string, string>("DequeueTo", DequeueTo)); } if (DequeueStatusCallbackUrl != null) { p.Add(new KeyValuePair <string, string>("DequeueStatusCallbackUrl", DequeueStatusCallbackUrl.AbsoluteUri.TrimEnd('/'))); } if (CallFrom != null) { p.Add(new KeyValuePair <string, string>("CallFrom", CallFrom)); } if (CallRecord != null) { p.Add(new KeyValuePair <string, string>("CallRecord", CallRecord)); } if (CallTimeout != null) { p.Add(new KeyValuePair <string, string>("CallTimeout", CallTimeout.Value.ToString())); } if (CallTo != null) { p.Add(new KeyValuePair <string, string>("CallTo", CallTo)); } if (CallUrl != null) { p.Add(new KeyValuePair <string, string>("CallUrl", CallUrl.AbsoluteUri.TrimEnd('/'))); } if (CallStatusCallbackUrl != null) { p.Add(new KeyValuePair <string, string>("CallStatusCallbackUrl", CallStatusCallbackUrl.AbsoluteUri.TrimEnd('/'))); } if (CallAccept != null) { p.Add(new KeyValuePair <string, string>("CallAccept", CallAccept.Value.ToString().ToLower())); } if (RedirectCallSid != null) { p.Add(new KeyValuePair <string, string>("RedirectCallSid", RedirectCallSid.ToString())); } if (RedirectAccept != null) { p.Add(new KeyValuePair <string, string>("RedirectAccept", RedirectAccept.Value.ToString().ToLower())); } if (RedirectUrl != null) { p.Add(new KeyValuePair <string, string>("RedirectUrl", RedirectUrl.AbsoluteUri.TrimEnd('/'))); } if (To != null) { p.Add(new KeyValuePair <string, string>("To", To)); } if (From != null) { p.Add(new KeyValuePair <string, string>("From", From)); } if (StatusCallback != null) { p.Add(new KeyValuePair <string, string>("StatusCallback", StatusCallback.AbsoluteUri.TrimEnd('/'))); } if (StatusCallbackMethod != null) { p.Add(new KeyValuePair <string, string>("StatusCallbackMethod", StatusCallbackMethod.ToString())); } if (StatusCallbackEvent != null) { p.AddRange(StatusCallbackEvent.Select(prop => new KeyValuePair <string, string>("StatusCallbackEvent", prop.ToString()))); } if (Timeout != null) { p.Add(new KeyValuePair <string, string>("Timeout", Timeout.Value.ToString())); } if (Record != null) { p.Add(new KeyValuePair <string, string>("Record", Record.Value.ToString().ToLower())); } if (Muted != null) { p.Add(new KeyValuePair <string, string>("Muted", Muted.Value.ToString().ToLower())); } if (Beep != null) { p.Add(new KeyValuePair <string, string>("Beep", Beep)); } if (StartConferenceOnEnter != null) { p.Add(new KeyValuePair <string, string>("StartConferenceOnEnter", StartConferenceOnEnter.Value.ToString().ToLower())); } if (EndConferenceOnExit != null) { p.Add(new KeyValuePair <string, string>("EndConferenceOnExit", EndConferenceOnExit.Value.ToString().ToLower())); } if (WaitUrl != null) { p.Add(new KeyValuePair <string, string>("WaitUrl", WaitUrl.AbsoluteUri.TrimEnd('/'))); } if (WaitMethod != null) { p.Add(new KeyValuePair <string, string>("WaitMethod", WaitMethod.ToString())); } if (EarlyMedia != null) { p.Add(new KeyValuePair <string, string>("EarlyMedia", EarlyMedia.Value.ToString().ToLower())); } if (MaxParticipants != null) { p.Add(new KeyValuePair <string, string>("MaxParticipants", MaxParticipants.Value.ToString())); } if (ConferenceStatusCallback != null) { p.Add(new KeyValuePair <string, string>("ConferenceStatusCallback", ConferenceStatusCallback.AbsoluteUri.TrimEnd('/'))); } if (ConferenceStatusCallbackMethod != null) { p.Add(new KeyValuePair <string, string>("ConferenceStatusCallbackMethod", ConferenceStatusCallbackMethod.ToString())); } if (ConferenceStatusCallbackEvent != null) { p.AddRange(ConferenceStatusCallbackEvent.Select(prop => new KeyValuePair <string, string>("ConferenceStatusCallbackEvent", prop.ToString()))); } if (ConferenceRecord != null) { p.Add(new KeyValuePair <string, string>("ConferenceRecord", ConferenceRecord)); } if (ConferenceTrim != null) { p.Add(new KeyValuePair <string, string>("ConferenceTrim", ConferenceTrim)); } if (RecordingChannels != null) { p.Add(new KeyValuePair <string, string>("RecordingChannels", RecordingChannels)); } if (RecordingStatusCallback != null) { p.Add(new KeyValuePair <string, string>("RecordingStatusCallback", RecordingStatusCallback.AbsoluteUri.TrimEnd('/'))); } if (RecordingStatusCallbackMethod != null) { p.Add(new KeyValuePair <string, string>("RecordingStatusCallbackMethod", RecordingStatusCallbackMethod.ToString())); } if (ConferenceRecordingStatusCallback != null) { p.Add(new KeyValuePair <string, string>("ConferenceRecordingStatusCallback", ConferenceRecordingStatusCallback.AbsoluteUri.TrimEnd('/'))); } if (ConferenceRecordingStatusCallbackMethod != null) { p.Add(new KeyValuePair <string, string>("ConferenceRecordingStatusCallbackMethod", ConferenceRecordingStatusCallbackMethod.ToString())); } if (Region != null) { p.Add(new KeyValuePair <string, string>("Region", Region)); } if (SipAuthUsername != null) { p.Add(new KeyValuePair <string, string>("SipAuthUsername", SipAuthUsername)); } if (SipAuthPassword != null) { p.Add(new KeyValuePair <string, string>("SipAuthPassword", SipAuthPassword)); } if (DequeueStatusCallbackEvent != null) { p.AddRange(DequeueStatusCallbackEvent.Select(prop => new KeyValuePair <string, string>("DequeueStatusCallbackEvent", prop))); } if (PostWorkActivitySid != null) { p.Add(new KeyValuePair <string, string>("PostWorkActivitySid", PostWorkActivitySid.ToString())); } return(p); }
/// <summary> /// Generate the necessary parameters /// </summary> public List <KeyValuePair <string, string> > GetParams() { var p = new List <KeyValuePair <string, string> >(); if (ReservationStatus != null) { p.Add(new KeyValuePair <string, string>("ReservationStatus", ReservationStatus.ToString())); } if (WorkerActivitySid != null) { p.Add(new KeyValuePair <string, string>("WorkerActivitySid", WorkerActivitySid.ToString())); } if (Instruction != null) { p.Add(new KeyValuePair <string, string>("Instruction", Instruction)); } if (DequeuePostWorkActivitySid != null) { p.Add(new KeyValuePair <string, string>("DequeuePostWorkActivitySid", DequeuePostWorkActivitySid.ToString())); } if (DequeueFrom != null) { p.Add(new KeyValuePair <string, string>("DequeueFrom", DequeueFrom)); } if (DequeueRecord != null) { p.Add(new KeyValuePair <string, string>("DequeueRecord", DequeueRecord)); } if (DequeueTimeout != null) { p.Add(new KeyValuePair <string, string>("DequeueTimeout", DequeueTimeout.Value.ToString())); } if (DequeueTo != null) { p.Add(new KeyValuePair <string, string>("DequeueTo", DequeueTo)); } if (DequeueStatusCallbackUrl != null) { p.Add(new KeyValuePair <string, string>("DequeueStatusCallbackUrl", DequeueStatusCallbackUrl.AbsoluteUri)); } if (CallFrom != null) { p.Add(new KeyValuePair <string, string>("CallFrom", CallFrom)); } if (CallRecord != null) { p.Add(new KeyValuePair <string, string>("CallRecord", CallRecord)); } if (CallTimeout != null) { p.Add(new KeyValuePair <string, string>("CallTimeout", CallTimeout.Value.ToString())); } if (CallTo != null) { p.Add(new KeyValuePair <string, string>("CallTo", CallTo)); } if (CallUrl != null) { p.Add(new KeyValuePair <string, string>("CallUrl", CallUrl.AbsoluteUri)); } if (CallStatusCallbackUrl != null) { p.Add(new KeyValuePair <string, string>("CallStatusCallbackUrl", CallStatusCallbackUrl.AbsoluteUri)); } if (CallAccept != null) { p.Add(new KeyValuePair <string, string>("CallAccept", CallAccept.Value.ToString())); } if (RedirectCallSid != null) { p.Add(new KeyValuePair <string, string>("RedirectCallSid", RedirectCallSid.ToString())); } if (RedirectAccept != null) { p.Add(new KeyValuePair <string, string>("RedirectAccept", RedirectAccept.Value.ToString())); } if (RedirectUrl != null) { p.Add(new KeyValuePair <string, string>("RedirectUrl", RedirectUrl.AbsoluteUri)); } return(p); }