public async Task <bool> PutRegisterAsync(PutRegister data) { var url = urlConst.Register; RestClient <PutRegister> restClient = new RestClient <PutRegister>(); return(await restClient.SaveItemAsync(data, url, false)); }
private async void UpdateItem() { var typeConst = new TypeMethod(); var urlConst = new UrlApi(); var registersServices = new RegistersServices(); if (!string.IsNullOrEmpty(Money.Text)) { var indexDtbSelected = DtbPicker.SelectedIndex; var indexItemSelected = ContentPicker.SelectedIndex; var status = false; double money = double.Parse(Money.Text); string description = string.IsNullOrEmpty(Description.Text) ? "" : Description.Text; string idUser = Application.Current.Properties["userId"].ToString(); if (indexDtbSelected == 0) { string type = typeConst.Cost; int idService = viewModel.ListCostsId[indexItemSelected]; PutRegister ItemCost = new PutRegister(id, type, money, description, idService); status = await registersServices.PutRegister(ItemCost); } else { string type = typeConst.Income; int idService = viewModel.ListIncomesId[indexItemSelected]; PutRegister ItemIncome = new PutRegister(id, type, money, description, idService); status = await registersServices.PutRegister(ItemIncome); } if (status) { await DisplayAlert("Thông báo", "Cập nhật thành công!", "ok"); await Navigation.PushAsync(new HomePage()); } else { await DisplayAlert("Thông báo", "Cập nhật không thành công. Vui lòng thử lại sau!", "ok"); } } else { await DisplayAlert("Thông báo", "Vui lòng nhập đầy đủ thông tin!", "cancel"); return; } }
public async Task <bool> PutRegister(PutRegister data) { RestClient <PutRegister> restClient = new RestClient <PutRegister>(); return(await restClient.PutAsync(data.id, data, urlConst.Register)); }