public static Expense ReadExpenseById(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 Expense()); } else { ExpenseWrapper expenseWrapper = JsonConvert.DeserializeObject <ExpenseWrapper>(encodedResponse); Singleton.GetInstance().ActualExpense = expenseWrapper; return(new Expense() { ExpenseId = expenseWrapper.Id, ExpenseDate = expenseWrapper.Date, ExpensePlace = expenseWrapper.Place, ExpenseInfo = expenseWrapper.Info, ExpenseMileage = expenseWrapper.Mileage, ExpensePrice = (double)expenseWrapper.Price, ExpenseTypeInfo = expenseWrapper.TypeInfo }); } }
public static Car ReadCarById(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 Car()); } else { CarWrapper carWrapper = JsonConvert.DeserializeObject <CarWrapper>(encodedResponse); Singleton.GetInstance().ActualCar = carWrapper; return(new Car() { CarId = carWrapper.Id, CarManufacturer = carWrapper.Manufacturer, CarModel = carWrapper.Model, CarFirstRegistrationDate = carWrapper.FirstRegistrationDate, CarActualMileage = carWrapper.ActualMileage, CarLicencePlate = carWrapper.LicencePlate, CarPurchaseDate = carWrapper.PurchaseDate, CarPurchaseMileage = carWrapper.PurchaseMileage, CarVin = carWrapper.Vin }); } }
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 }); } }
public static string DeleteCarById(int id, ComboBox comboBoxCars) { RequestProvider requestProvider = new RequestProvider(deleteUri); requestProvider.Id = id; byte[] response = requestProvider.performGet(); string encodedResponse = Encoding.UTF8.GetString(response, 0, response.Length); if (errorsDelete.Contains(encodedResponse)) { return(encodedResponse); } else { CmbElement cmbElementDeleted = (CmbElement)comboBoxCars.SelectedItem; ObservableCollection <CmbElement> cmbList = (ObservableCollection <CmbElement>)comboBoxCars.ItemsSource; CmbElement cmbElementNext = cmbList.Single(i => i.Value == "<Create>"); comboBoxCars.SelectedItem = cmbElementNext; cmbList.Remove(cmbElementDeleted); comboBoxCars.ItemsSource = cmbList; return(encodedResponse); } }