public static async Task <bool> save(DebitCard debitCard) { bool response = true; try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "debit_cards")); cparams.Add(new CloureParam("topic", "guardar")); cparams.Add(new CloureParam("id", debitCard.Id.ToString())); cparams.Add(new CloureParam("nombre", debitCard.Name)); string res = await CloureManager.ExecuteAsync(cparams); JsonObject api_result = JsonObject.Parse(res); string error = api_result.GetNamedString("Error"); if (error == "") { JsonObject api_response = api_result.GetNamedObject("Response"); } else { throw new Exception(error); } } catch (Exception ex) { response = false; var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(response); }
private void lstItems_RightTapped(object sender, RightTappedRoutedEventArgs e) { ListView listView = (ListView)sender; itemContextMenu.Items.Clear(); ListView list = (ListView)sender; DebitCard bank = (DebitCard)((FrameworkElement)e.OriginalSource).DataContext; if (bank.availableCommands.Count > 0) { foreach (AvailableCommand availableCommand in bank.availableCommands) { MenuFlyoutItem menuFlyoutItem = new MenuFlyoutItem(); menuFlyoutItem.Text = availableCommand.title; menuFlyoutItem.Name = availableCommand.name; menuFlyoutItem.Tag = bank; menuFlyoutItem.Click += MenuFlyoutItem_Click; itemContextMenu.Items.Add(menuFlyoutItem); } } if (itemContextMenu.Items.Count > 0) { itemContextMenu.ShowAt(listView, e.GetPosition(listView)); var a = ((FrameworkElement)e.OriginalSource).DataContext; } }
public static async Task <List <DebitCard> > getList(string filtro = "") { List <DebitCard> response = new List <DebitCard>(); try { List <CloureParam> cparams = new List <CloureParam>(); cparams.Add(new CloureParam("module", "debit_cards")); cparams.Add(new CloureParam("topic", "listar")); string res = await CloureManager.ExecuteAsync(cparams); JsonObject api_result = JsonObject.Parse(res); string error = api_result.GetNamedString("Error"); if (error == "") { JsonObject api_response = api_result.GetNamedObject("Response"); JsonArray registers = api_response.GetNamedArray("Registros"); foreach (JsonValue jsonValue in registers) { JsonObject register = jsonValue.GetObject(); DebitCard item = new DebitCard(); item.Id = (int)register.GetNamedNumber("Id"); item.Name = register.GetNamedString("Nombre"); JsonArray available_commands_arr = register.GetNamedArray("AvailableCommands"); item.availableCommands = new List <AvailableCommand>(); foreach (JsonValue available_cmd_obj in available_commands_arr) { JsonObject available_cmd_item = available_cmd_obj.GetObject(); int available_cmd_id = (int)available_cmd_item.GetNamedNumber("Id"); string available_cmd_name = available_cmd_item.GetNamedString("Name"); string available_cmd_title = available_cmd_item.GetNamedString("Title"); AvailableCommand availableCommand = new AvailableCommand(available_cmd_id, available_cmd_name, available_cmd_title); item.availableCommands.Add(availableCommand); } response.Add(item); } } else { throw new Exception(error); } } catch (Exception ex) { var dialog = new MessageDialog(ex.Message); await dialog.ShowAsync(); } return(response); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); if (e.Parameter != null) { if (e.Parameter.GetType() == typeof(DebitCard)) { creditCard = (DebitCard)e.Parameter; txtNombre.Text = creditCard.Name; } } }
private async void Save() { if (creditCard == null) { creditCard = new DebitCard(); creditCard.Id = 0; } creditCard.Name = txtNombre.Text; if (await DebitCards.save(creditCard)) { CloureManager.GoBack("reload"); } }
private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e) { MenuFlyoutItem menuFlyoutItem = (MenuFlyoutItem)sender; DebitCard bank = (DebitCard)menuFlyoutItem.Tag; if (menuFlyoutItem.Name == "edit") { edit(bank); } if (menuFlyoutItem.Name == "delete") { DisplayDeleteDialog(bank); } }
private async void DisplayDeleteDialog(DebitCard bank) { ContentDialog deleteFileDialog = new ContentDialog { Title = "¿Está seguro que desea eliminar este registro?", Content = "El registro se borrará de forma permanente", PrimaryButtonText = "Borrar", CloseButtonText = "Cancelar" }; ContentDialogResult result = await deleteFileDialog.ShowAsync(); // Delete the file if the user clicked the primary button. /// Otherwise, do nothing. if (result == ContentDialogResult.Primary) { bool api_result = await DebitCards.Delete(bank.Id); if (api_result) { LoadData(); } } }
void edit(DebitCard bank) { CloureManager.Navigate(typeof(DebitCardAddPage), bank); }
private void lstItems_ItemClick(object sender, ItemClickEventArgs e) { DebitCard bank = (DebitCard)e.ClickedItem; edit(bank); }