コード例 #1
0
        async Task Set()
        {
            try
            {
                if (ChangeCard.BonusCardID != 0)
                {
                    if (ChangeCard.RemuveSumm > 0)
                    {
                        string operationsjson = JsonConvert.SerializeObject(new QueryParamDTO()
                        {
                            BonusCardNumber = $"{ChangeCard.BonusCardNumber}", UserPhoneNumber = $"{ChangeCard.UserPhoneNumber}", MoneyFromBonusCard = ChangeCard.RemuveSumm
                        });
                        var paramOperations = new SendParams(String.Concat(UrlHelper.Domain, UrlHelper.MoneyFromBonusCard),
                                                             operationsjson, "POST");
                        var sendOperations = new Helpers.RestClient(paramOperations);
                        await sendOperations.Post();

                        var ResponseOperations = (string)JsonConvert.DeserializeObject(sendOperations.Response, typeof(string));
                        textBlock.Text = $"Карта:{ChangeCard.BonusCardNumber}; Баланс:{ChangeCard.BonusCardBalanse -= (decimal)ChangeCard.RemuveSumm}";
                        ///MessageBox.Show(ResponseOperations);
                    }
                    if (ChangeCard.AddSumm > 0)
                    {
                        string operationsjson = JsonConvert.SerializeObject(new QueryParamDTO()
                        {
                            BonusCardNumber = $"{ChangeCard.BonusCardNumber}", UserPhoneNumber = $"{ChangeCard.UserPhoneNumber}", MoneyFromBonusCard = ChangeCard.AddSumm
                        });
                        var paramOperations = new SendParams(String.Concat(UrlHelper.Domain, UrlHelper.MoneyToBonusCard),
                                                             operationsjson, "POST");
                        var sendOperations = new Helpers.RestClient(paramOperations);
                        await sendOperations.Post();

                        var ResponseOperations = (string)JsonConvert.DeserializeObject(sendOperations.Response, typeof(string));
                        textBlock.Text = $"Карта:{ChangeCard.BonusCardNumber}; Баланс:{ChangeCard.BonusCardBalanse += (decimal)ChangeCard.AddSumm}";
                        //MessageBox.Show(ResponseOperations);
                    }
                    await Get(Summ.State);
                }
                else
                {
                    MessageBox.Show("Карта не выбрана");
                }
            }
            catch
            {
                MessageBox.Show("Не удалось обработать запрос обратитесь за помощью в службу поддержки");
            }
        }
コード例 #2
0
        private async void Button_Click_2(object sender, RoutedEventArgs e)
        {
            try
            {
                var paramOperations = new SendParams(String.Concat(UrlHelper.Domain, UrlHelper.CreateBonusCard),
                                                     "", "POST");
                var sendOperations = new Helpers.RestClient(paramOperations);
                await sendOperations.Post();

                var ResponseOperations = (string)JsonConvert.DeserializeObject(sendOperations.Response, typeof(string));
                MessageBox.Show(ResponseOperations);
            }
            catch
            {
                MessageBox.Show("Не удалось обработать запрос обратитесь за помощью в службу поддержки");
            }
        }
コード例 #3
0
        async Task Get(string sender)
        {
            try
            {
                string operationsjson = JsonConvert.SerializeObject(new QueryParamDTO()
                {
                    BonusCardNumber = $"{sender}", UserPhoneNumber = $"{sender}"
                });
                var paramOperations = new SendParams(String.Concat(UrlHelper.Domain, UrlHelper.GetCards),
                                                     operationsjson, "POST");

                var sendOperations = new Helpers.RestClient(paramOperations);

                await sendOperations.Post();

                var ResponseOperations = (ObservableCollection <ViewModel>)JsonConvert.DeserializeObject(sendOperations.Response, typeof(ObservableCollection <ViewModel>));
                this.new_ViewModel.ItemsSource = ResponseOperations;
                Summ.State = sender;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }