示例#1
0
        public async Task <bool> PutRegisterAsync(PutRegister data)
        {
            var url = urlConst.Register;

            RestClient <PutRegister> restClient = new RestClient <PutRegister>();

            return(await restClient.SaveItemAsync(data, url, false));
        }
示例#2
0
        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;
            }
        }
示例#3
0
        public async Task <bool> PutRegister(PutRegister data)
        {
            RestClient <PutRegister> restClient = new RestClient <PutRegister>();

            return(await restClient.PutAsync(data.id, data, urlConst.Register));
        }