Example #1
0
        public static string CreateExpense(ComboBox comboBoxExpenses, Dictionary <string, string> paramDictionary, ref int counter)
        {
            RequestProvider requestProvider = new RequestProvider(createUri);

            requestProvider.Parameters = paramDictionary;
            byte[] response        = requestProvider.performPost();
            string encodedResponse = Encoding.UTF8.GetString(response, 0, response.Length);

            if (errorsCreate.Contains(encodedResponse))
            {
                return(encodedResponse);
            }
            ExpenseWrapper expenseWrapper = JsonConvert.DeserializeObject <ExpenseWrapper>(encodedResponse);

            Singleton.GetInstance().ActualCar.ExpenseList.Add(expenseWrapper.Id);
            ObservableCollection <CmbElement> cmbList = (ObservableCollection <CmbElement>)comboBoxExpenses.ItemsSource;
            CmbElement cmbElementActual = new CmbElement {
                Id = counter++, Value = expenseWrapper.Id.ToString()
            };

            cmbList.Add(cmbElementActual);
            comboBoxExpenses.ItemsSource  = cmbList;
            comboBoxExpenses.SelectedItem = cmbElementActual;
            return("Correct");
        }
Example #2
0
        private string UserOperation(string Login, string Password, string Uri)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("Login", Login);
            parameters.Add("Password", Password);
            RequestProvider requestProvider = new RequestProvider(Uri);

            requestProvider.Parameters = parameters;
            byte[] response = requestProvider.performPost();
            return(Encoding.UTF8.GetString(response, 0, response.Length));
        }
Example #3
0
        public static string UpdateExpense(Dictionary <string, string> paramDictionary)
        {
            RequestProvider             requestProvider = new RequestProvider(updateUri);
            Dictionary <string, string> parameters      = paramDictionary;

            requestProvider.Parameters = parameters;
            byte[] response        = requestProvider.performPost();
            string encodedResponse = Encoding.UTF8.GetString(response, 0, response.Length);

            if (errorsUpdate.Contains(encodedResponse))
            {
                return(encodedResponse);
            }
            return(encodedResponse);
        }