Esempio n. 1
0
        /// <summary>
        /// Send SMS. Refer to : <see href="https://api.voxity.fr/doc/#api-SMS-SendSms"/>
        /// </summary>
        /// <param name="content">Message content</param>
        /// <param name="phoneNumber">[FORMAT: /^[0-9]{ 10}$/] Phone number for the message receiver</param>
        /// <param name="emitter">(Optional) [FORMAT: /^([a-z]|[A-Z]){4,11}$/] The emitter's name. Be aware that the receiver cannot respond to the message if this field is specified.</param>
        /// <returns><see cref="NewSms"/> object.</returns>
        public NewSms SendMessage(string content, string phoneNumber, string emitter = null)
        {
            if (Utils.Filter.ValidPhone(phoneNumber) != true && Utils.Filter.ValidRac(phoneNumber) != true)
            {
                throw new ApiSessionException("Invalid phone number.");
            }

            CreateSms cs = new CreateSms();

            if (!string.IsNullOrWhiteSpace(phoneNumber))
            {
                cs.phone_number = phoneNumber;
            }

            if (!string.IsNullOrWhiteSpace(content))
            {
                cs.content = content;
            }

            if (!string.IsNullOrWhiteSpace(emitter))
            {
                cs.emitter = emitter;
            }

            HttpResponseMessage response = smsSession.Request(ApiSession.HttpMethod.Post, "sms", contentType: "application/json", contentValue: JsonConvert.SerializeObject(cs, Formatting.None, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            }));

            if (response.IsSuccessStatusCode)
            {
                return(JsonConvert.DeserializeObject <ApiResponse <NewSms> >(response.Content.ReadAsStringAsync().Result).Results());
            }
            else
            {
                switch (response.StatusCode)
                {
                default:
                    throw new HttpRequestException(response.StatusCode.ToString());
                }
            }
        }
Esempio n. 2
0
        public void LoadView(ViewType typeView)
        {
            switch (typeView)
            {
            case ViewType.Main:
                //загружаем вьюшку, ее вьюмодель
                MainWindowVM mainWindowVM = new MainWindowVM(idUser);
                MainWindow   mainWindow   = new MainWindow();
                mainWindowVM.CodeBehind = mainWindow;
                mainWindow.DataContext  = mainWindowVM;
                MainControl   view = new MainControl();
                MainControlVM vm   = new MainControlVM(idUser);
                view.DataContext = vm;
                //отображаем
                this.ContentPresenterOutput.Content = view;
                break;

            case ViewType.AddBalance:
                //загружаем вьюшку, ее вьюмодель
                AddBalance   addBalanceView = new AddBalance();
                AddBalanceVM AddBalanceVm   = new AddBalanceVM(idUser);
                addBalanceView.DataContext = AddBalanceVm;
                //отображаем
                this.ContentPresenterOutput.Content = addBalanceView;
                break;

            case ViewType.CallAndSms:
                //загружаем вьюшку, ее вьюмодель
                CallAndSms   callAndSmsView = new CallAndSms();
                CallAndSmsVM callAndSmsVm   = new CallAndSmsVM(idUser, this);
                callAndSmsView.DataContext = callAndSmsVm;
                //отображаем
                this.ContentPresenterOutput.Content = callAndSmsView;
                break;

            case ViewType.Tariff:
                //загружаем вьюшку, ее вьюмодель
                Tariff   tariffview = new Tariff();
                TariffVM tariffVm   = new TariffVM(idUser);
                tariffview.DataContext = tariffVm;
                //отображаем
                this.ContentPresenterOutput.Content = tariffview;
                break;

            case ViewType.Service:
                //загружаем вьюшку, ее вьюмодель
                Service   serviceView = new Service();
                ServiceVM serviceVM   = new ServiceVM(idUser);
                serviceView.DataContext = serviceVM;
                //отображаем
                this.ContentPresenterOutput.Content = serviceView;
                break;

            case ViewType.CreateCall:
                //загружаем вьюшку, ее вьюмодель
                CreateCall   callView = new CreateCall();
                CreateCallVM callVM   = new CreateCallVM(idUser, this);
                callView.DataContext = callVM;
                //отображаем
                this.ContentPresenterOutput.Content = callView;
                break;

            case ViewType.CreateSms:
                //загружаем вьюшку, ее вьюмодель
                CreateSms   smsView = new CreateSms();
                CreateSmsVM smsVM   = new CreateSmsVM(idUser, this);
                smsView.DataContext = smsVM;
                //отображаем
                this.ContentPresenterOutput.Content = smsView;
                break;

                /*case ViewType.CheckListForPdf:
                 *  //загружаем вьюшку, ее вьюмодель
                 *  CheckListForPdf CheckListForPdfView = new CheckListForPdf();
                 *  CheckListForPdfVM checkListForPdfVM = new CheckListForPdfVM(idUser,Convert.ToDateTime("01.01.2000"), Convert.ToDateTime("01.01.2020"));
                 *  //checkListForPdfVM.CodeBehind = CheckListForPdfView;
                 *  CheckListForPdfView.DataContext = checkListForPdfVM;
                 *  CheckListForPdfView.Show();
                 *//*                    //отображаем
                 *                      this.ContentPresenterOutput.Content = CheckListForPdfView;*//*
                 *  break;*/
            }
        }