Exemplo n.º 1
0
        public static Reminder ReadReminderById(int id)
        {
            RequestProvider requestProvider = new RequestProvider(readUri);

            requestProvider.Id = id;
            byte[] response        = requestProvider.performGet();
            string encodedResponse = Encoding.UTF8.GetString(response, 0, response.Length);

            if (errorsRead.Contains(encodedResponse))
            {
                MainWindow.ShowErrorInfo(encodedResponse);
                return(new Reminder());
            }
            else
            {
                ReminderWrapper reminderWrapper        = JsonConvert.DeserializeObject <ReminderWrapper>(encodedResponse);
                Singleton.GetInstance().ActualReminder = reminderWrapper;
                return(new Reminder()
                {
                    ReminderId = reminderWrapper.Id,
                    ReminderDate = reminderWrapper.Date,
                    ReminderInfo = reminderWrapper.Info,
                    ReminderIsChecked = reminderWrapper.IsChecked,
                    ReminderMilleage = reminderWrapper.Milleage
                });
            }
        }
Exemplo n.º 2
0
        public static string CreateReminder(ComboBox comboBoxReminders, 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);
            }
            ReminderWrapper reminderWrapper = JsonConvert.DeserializeObject <ReminderWrapper>(encodedResponse);

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

            cmbList.Add(cmbElementActual);
            comboBoxReminders.ItemsSource  = cmbList;
            comboBoxReminders.SelectedItem = cmbElementActual;
            return("Correct");
        }