internal override async System.Threading.Tasks.Task Send(IEnumerable<Task> tasks, IMobileServiceTable<Task> tasksTable, IEnumerable<TaskAssignedTo> taskAssignedToRelationship, IMobileServiceTable<TaskAssignedTo> taskAssignedToTable, Person user) { var taskAssignedTo = taskAssignedToRelationship.FirstOrDefault(p => p.TaskId == this.TaskId && p.PersonUserId == user.UserId); //TODO: Onlinescore. Score übernehmen geschieht beim LogIn. Bisher. if (taskAssignedTo == null || (taskAssignedTo.Id == 0)) { //Fehlerfall silent lösen, sollte eigentlich nie vorkommen! //Gehe einfach davon aus es sein nichts passiert :D if (System.Diagnostics.Debugger.IsAttached) System.Diagnostics.Debugger.Break(); } else { if (taskAssignedTo.PersonUserId == "") taskAssignedTo.PersonUserId = user.UserId; await taskAssignedToTable.UpdateAsync(taskAssignedTo); } }
public ViewInvitesViewModel(MainViewModel parent, IMobileServiceTable<Invite> invitesTable, Action dismiss) { _parent = parent; _invitesTable = invitesTable; Invites = parent.Invites; AcceptCommand = new DelegateCommand<Invite>(async invite => { invite.Approved = true; await _invitesTable.UpdateAsync(invite); Invites.Remove(invite); _parent.LoadLists(); _parent.ViewInvitesCommand.IsEnabled = Invites.Count > 0; if (Invites.Count == 0 ) { dismiss(); } }); RejectCommand = new DelegateCommand<Invite>(async invite => { await _invitesTable.UpdateAsync(invite); Invites.Remove(invite); _parent.ViewInvitesCommand.IsEnabled = Invites.Count > 0; if (Invites.Count == 0) { dismiss(); } }); }
internal override async System.Threading.Tasks.Task Send(IEnumerable<Task> tasks, IMobileServiceTable<Task> tasksTable, IEnumerable<TaskAssignedTo> taskAssignedToRelationship, IMobileServiceTable<TaskAssignedTo> taskAssignedToTable, Person user) { var task = tasks.FirstOrDefault(p => p.TaskId == TaskId); if (task != null && task.Id != 0) //Wenn einfügen nicht erfolgreich war ist auch alles egal. await tasksTable.UpdateAsync(task); var taskAssignedTo = taskAssignedToRelationship.FirstOrDefault(p => p.TaskId == this.TaskId && p.PersonUserId == user.UserId); if (taskAssignedTo != null && taskAssignedTo.Id != 0) //Wenn einfügen nicht erfolgreich war ist auch alles egal. await taskAssignedToTable.UpdateAsync(taskAssignedTo); }
async Task updateAsync <T> (IMobileServiceTable <T> table, T item) #endif where T : AzureEntity, new() { #if DEBUG var sw = new System.Diagnostics.Stopwatch(); sw.Start(); #endif try { await table?.UpdateAsync(item); #if OFFLINE_SYNC_ENABLED if (pull) { sync(table, where); } #endif } catch (MobileServicePreconditionFailedException <T> preconditionFailed) { log($"UpdateItemAsync for {typeof (T).Name} failed due to a conflict detected between the local and server version : {(preconditionFailed.InnerException ?? preconditionFailed).Message}"); // To resolve the conflict, update the version of the item being committed. Otherwise, // it will continue to throw MobileServicePreConditionFailedExceptions item.Version = preconditionFailed.Item.Version; // Updating recursively here just in case another change happened while the user was making a decision await updateAsync(table, item); #if !DEBUG } catch (Exception) { throw; #else } catch (Exception e) { logDebug <T> (e); throw; } finally { sw.Stop(); logDebug <T> (sw.ElapsedMilliseconds); #endif } }
private async void btnactualizar_Clicked(object sender, EventArgs e) { if (txtTarea.Text == null) { await DisplayAlert("Error", "Es obligatorio llenar todos los campos", "OK"); } else { var datos = new tareasmire { Tarea = txtTarea.Text, Descripcion = txtDescripcion.Text }; try { await Tabla2.UpdateAsync(datos); await DisplayAlert("Actualizacion", "Tarea Actualizada correctamente", "OK"); } catch (Exception error) { await DisplayAlert("error", "" + error, "OK"); } } }
public async void sacuvajPromjene(object p) { /*foreach (Korisnik k in KAerodrom.Korisnici) * { * if (k.Id == Korisnik.Id) * { * KAerodrom.Korisnici.Remove(k); * KAerodrom.Korisnici.Add(Korisnik); * Messenger.prikaziPoruku("Promjene uspjesno sačuvane."); * break; * } * }*/ if (obj != null) { obj.ime = Korisnik.Ime; obj.prezime = Korisnik.Prezime; obj.korisnickoIme = Korisnik.KorisnickoIme; obj.lozinka = Korisnik.Lozinka; obj.datumRodjenja = Korisnik.DatumRodjenja; obj.brojTelefona = Korisnik.BrojTelefona; obj.brojKreditneKartice = Korisnik.BrojKreditneKartice; obj.adresaStanovanja = Korisnik.AdresaStanovanja; obj.opcija1Mjesec = Korisnik.Opcija1Mjesec; obj.opcija6Mjeseci = Korisnik.Opcija6Mjeseci; obj.opcija12Mjeseci = Korisnik.Opcija12Mjeseci; obj.admin = Korisnik.Admin; obj.priv = Korisnik.Priv; obj.jmbg = Korisnik.Jmbg; obj.email = Korisnik.Email; await tabelaKorisnika.UpdateAsync(obj); Messenger.prikaziPoruku("Promjene uspješno sačuvane!"); } }
public async Task CheckItem(Products item) { if (client == null) { return; } // Set the item as completed and update it in the table item.Deleted = true; try { // Update the new item in the local store. await productTable.UpdateAsync(item); if (item.Deleted) { adapter.Remove(item); } } catch (Exception e) { CreateAndShowDialog(e, "Error"); } }
private async void Option1_Click(object sender, RoutedEventArgs e) { Button temp = sender as Button; idea i = temp.DataContext as idea; if (ids != null) { if (ids.Contains(i.Id)) { Windows.UI.Popups.MessageDialog mess = new Windows.UI.Popups.MessageDialog("You have already voted for this idea"); await mess.ShowAsync(); } else { ids.Add(i.Id); string test = JsonConvert.SerializeObject(ids); StorageFolder folder = Windows.Storage.ApplicationData.Current.LocalFolder; StorageFile sampleFile = await folder.CreateFileAsync("sample.txt", CreationCollisionOption.ReplaceExisting); await Windows.Storage.FileIO.WriteTextAsync(sampleFile, test); i.Countoption1++; await Table.UpdateAsync(i); } } else { ids = new List <string>(); ids.Add(i.Id); string test = JsonConvert.SerializeObject(ids); StorageFolder folder = Windows.Storage.ApplicationData.Current.LocalFolder; StorageFile sampleFile = await folder.CreateFileAsync("sample.txt", CreationCollisionOption.ReplaceExisting); await Windows.Storage.FileIO.WriteTextAsync(sampleFile, test); i.Countoption1++; await Table.UpdateAsync(i); } }
public async Task AsyncTableOperationsWithValidStringIdAgainstStringIdTable() { await EnsureEmptyTableAsync <ToDoWithStringId>(); string[] testIdData = IdTestData.ValidStringIds; foreach (string testId in testIdData) { IMobileServiceTable <ToDoWithStringId> table = GetClient().GetTable <ToDoWithStringId>(); ToDoWithStringId item = new ToDoWithStringId() { Id = testId, String = "Hey" }; await table.InsertAsync(item); // Read IEnumerable <ToDoWithStringId> results = await table.ReadAsync(); ToDoWithStringId[] items = results.ToArray(); Assert.AreEqual(1, items.Count()); Assert.AreEqual(testId, items[0].Id); Assert.AreEqual("Hey", items[0].String); // Filter results = await table.Where(i => i.Id == testId).ToEnumerableAsync(); items = results.ToArray(); Assert.AreEqual(1, items.Count()); Assert.AreEqual(testId, items[0].Id); Assert.AreEqual("Hey", items[0].String); // Projection var projectedResults = await table.Select(i => new { XId = i.Id, XString = i.String }).ToEnumerableAsync(); var projectedItems = projectedResults.ToArray(); Assert.AreEqual(1, projectedItems.Count()); Assert.AreEqual(testId, projectedItems[0].XId); Assert.AreEqual("Hey", projectedItems[0].XString); // Lookup item = await table.LookupAsync(testId); Assert.AreEqual(testId, item.Id); Assert.AreEqual("Hey", item.String); // Update item.String = "What?"; await table.UpdateAsync(item); Assert.AreEqual(testId, item.Id); Assert.AreEqual("What?", item.String); // Refresh item = new ToDoWithStringId() { Id = testId, String = "Hey" }; await table.RefreshAsync(item); Assert.AreEqual(testId, item.Id); Assert.AreEqual("What?", item.String); // Read Again results = await table.ReadAsync(); items = results.ToArray(); Assert.AreEqual(1, items.Count()); Assert.AreEqual(testId, items[0].Id); Assert.AreEqual("What?", items[0].String); await table.DeleteAsync(item); } }
public async Task AsyncTableOperationsWithIntegerAsStringIdAgainstIntIdTable() { await EnsureEmptyTableAsync <ToDoWithStringIdAgainstIntIdTable>(); IMobileServiceTable <ToDoWithStringIdAgainstIntIdTable> stringIdTable = GetClient().GetTable <ToDoWithStringIdAgainstIntIdTable>(); ToDoWithStringIdAgainstIntIdTable item = new ToDoWithStringIdAgainstIntIdTable() { String = "Hey" }; // Insert await stringIdTable.InsertAsync(item); string testId = item.Id.ToString(); // Read IEnumerable <ToDoWithStringIdAgainstIntIdTable> results = await stringIdTable.ReadAsync(); ToDoWithStringIdAgainstIntIdTable[] items = results.ToArray(); Assert.AreEqual(1, items.Count()); Assert.AreEqual(testId, items[0].Id); Assert.AreEqual("Hey", items[0].String); // Filter results = await stringIdTable.Where(i => i.Id == testId).ToEnumerableAsync(); items = results.ToArray(); Assert.AreEqual(1, items.Count()); Assert.AreEqual(testId, items[0].Id); Assert.AreEqual("Hey", items[0].String); // Projection var projectedResults = await stringIdTable.Select(i => new { XId = i.Id, XString = i.String }).ToEnumerableAsync(); var projectedItems = projectedResults.ToArray(); Assert.AreEqual(1, projectedItems.Count()); Assert.AreEqual(testId, projectedItems[0].XId); Assert.AreEqual("Hey", projectedItems[0].XString); // Lookup ToDoWithStringIdAgainstIntIdTable stringIdItem = await stringIdTable.LookupAsync(testId); Assert.AreEqual(testId, stringIdItem.Id); Assert.AreEqual("Hey", stringIdItem.String); // Update stringIdItem.String = "What?"; await stringIdTable.UpdateAsync(stringIdItem); Assert.AreEqual(testId, stringIdItem.Id); Assert.AreEqual("What?", stringIdItem.String); // Refresh stringIdItem = new ToDoWithStringIdAgainstIntIdTable() { Id = testId, String = "Hey" }; await stringIdTable.RefreshAsync(stringIdItem); Assert.AreEqual(testId, stringIdItem.Id); Assert.AreEqual("What?", stringIdItem.String); // Read Again results = await stringIdTable.ReadAsync(); items = results.ToArray(); Assert.AreEqual(1, items.Count()); Assert.AreEqual(testId, items[0].Id); Assert.AreEqual("What?", items[0].String); // Delete await stringIdTable.DeleteAsync(item); }
public static async Task UpdateData(Fund fund) { await fundTable.UpdateAsync(fund); }
public async Task UpdateAsyncWitMergeConflict_Generic() { await EnsureEmptyTableAsync <ToDoWithSystemPropertiesType>(); string id = "an id"; IMobileServiceTable <ToDoWithSystemPropertiesType> table = GetClient().GetTable <ToDoWithSystemPropertiesType>(); ToDoWithSystemPropertiesType item = new ToDoWithSystemPropertiesType() { Id = id, String = "a value" }; await table.InsertAsync(item); Assert.IsNotNull(item.CreatedAt); Assert.IsNotNull(item.UpdatedAt); Assert.IsNotNull(item.Version); string version = item.Version; // Update item.String = "Hello!"; await table.UpdateAsync(item); Assert.IsNotNull(item.Version); Assert.AreNotEqual(item.Version, version); string newVersion = item.Version; // Update again but with the original version item.Version = version; item.String = "But wait!"; MobileServicePreconditionFailedException <ToDoWithSystemPropertiesType> expectedException = null; try { await table.UpdateAsync(item); } catch (MobileServicePreconditionFailedException <ToDoWithSystemPropertiesType> exception) { expectedException = exception; } Assert.IsNotNull(expectedException); Assert.AreEqual(expectedException.Response.StatusCode, HttpStatusCode.PreconditionFailed); string responseContent = await expectedException.Response.Content.ReadAsStringAsync(); JToken jtoken = responseContent.ParseToJToken(table.MobileServiceClient.SerializerSettings); string serverVersion = (string)jtoken["version"]; string stringValue = (string)jtoken["String"]; Assert.AreEqual(newVersion, serverVersion); Assert.AreEqual(stringValue, "Hello!"); Assert.IsNotNull(expectedException.Item); Assert.AreEqual(newVersion, expectedException.Item.Version); Assert.AreEqual(stringValue, expectedException.Item.String); // Update one last time with the version from the server item.Version = serverVersion; await table.UpdateAsync(item); Assert.IsNotNull(item.Version); Assert.AreEqual(item.String, "But wait!"); Assert.AreNotEqual(item.Version, serverVersion); await table.DeleteAsync(item); }
private async void UpdateCheckedTodoItem(PARENTS item) { await todoTable.UpdateAsync(item); }
public async Task UpdateReminder(Reminder reminder) { await _reminderTable.UpdateAsync(reminder); UpdateEvent?.Invoke(reminder); }
public async void Update(EventInvites item) { // This code takes a freshly completed Events and updates the database. When the MobileService // responds, the item is removed from the list await mobileServiceTable.UpdateAsync(item); }
public async void OnExtendClick() { var parkingLimit = FindViewById <TextView>(Resource.Id.parking_limit); var extendBtn = FindViewById <Button>(Resource.Id.btn_extend); var extendedHours = FindViewById <EditText>(Resource.Id.input_hr); string sessionID = extendBtn.GetTag(Resource.Id.btn_extend).ToString(); Wallet wallet = await GetWalletData(); Parking parking = await GetLastParking(); if (String.IsNullOrEmpty(extendedHours.Text)) { Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetTitle("Parking Area"); alert.SetMessage("Fill in the required fields"); alert.SetPositiveButton("Ok", (senderAlertSucces, argsSuccess) => { }); Dialog dialogSuccess = alert.Create(); dialogSuccess.Show(); } else { int totalParkingAmount = 2 * Convert.ToInt32(extendedHours.Text); Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetTitle("Confirm Extending Current Session"); alert.SetMessage(parkingLimit.Text + "\n\nYou are trying to extend by: " + extendedHours.Text + " Hours" + "\nWallet Balance: " + wallet.Balance + "\nCharge Per Hour: " + "RM 2.00" + "\nTotal Payment: " + "RM " + totalParkingAmount); alert.SetPositiveButton("Yes", async(senderAlert, args) => { var parkingDialog = ProgressDialog.Show(this, "Please wait...", "Confirming your extension...", true); if (Convert.ToInt32(wallet.Balance) >= totalParkingAmount) { IMobileServiceTable <Wallet> walletData = client.GetTable <Wallet>(); IMobileServiceTable <Parking> parkingData = client.GetTable <Parking>(); wallet.Balance = Convert.ToString(Convert.ToInt32(wallet.Balance) - totalParkingAmount); parking.ParkedHours = Convert.ToInt32(parking.ParkedHours) + Convert.ToInt32(extendedHours.Text); var extraParameters = new Dictionary <string, string>(); extraParameters.Add("userId", user.Id); extraParameters.Add("type", "extend"); extraParameters.Add("parkingId", parking.Id); await parkingData.UpdateAsync(parking); await walletData.UpdateAsync(wallet, extraParameters); Android.App.AlertDialog.Builder alertSuccess = new Android.App.AlertDialog.Builder(this); alertSuccess.SetTitle("Time Extended"); alertSuccess.SetMessage("Payment is successful"); alertSuccess.SetPositiveButton("Ok", (senderAlertSucces, argsSuccess) => { RefreshActivity(); }); Dialog dialog = alertSuccess.Create(); dialog.Show(); } else { GoToTopUpWallet(Convert.ToInt32(wallet.Balance), totalParkingAmount); } }); alert.SetNegativeButton("Cancel", (senderAlert, args) => { Toast.MakeText(this, "Cancelled!", ToastLength.Short).Show(); }); Dialog dialogSuccess = alert.Create(); dialogSuccess.Show(); } }
private async void btRx() { App.btRxStarted = true; try { // Based on the protocol we've defined, the first uint is the size of the message uint readLength = await App._btReader.LoadAsync(1); char readChar = (char)App._btReader.ReadByte(); //char dummy = (char)App._btReader.ReadByte(); Debug.WriteLine("char recieved: " + readChar); while (readChar != 'x' && readChar != 'w') { readLength = await App._btReader.LoadAsync(1); readChar = (char)App._btReader.ReadByte(); //char dummy = (char)App._btReader.ReadByte(); Debug.WriteLine("char recieved: " + readChar); } if (App.enableX == true) { ButtonStart.IsEnabled = true; if (readChar == 'x') { var PlayMusic = new MediaElement(); StorageFolder Folder = Windows.ApplicationModel.Package.Current.InstalledLocation; Folder = await Folder.GetFolderAsync("Sound"); StorageFile sf = await Folder.GetFileAsync("Pacman-lost.mp3"); PlayMusic.SetSource(await sf.OpenAsync(FileAccessMode.Read), sf.ContentType); PlayMusic.Play(); if (App.playerNum != 1 && App.game.Player1 != "" && App.game.PlayerQuit1 == false) { App.game.PointsPlayer1++; } if (App.playerNum != 2 && App.game.Player2 != "" && App.game.PlayerQuit2 == false) { App.game.PointsPlayer2++; } if (App.playerNum != 3 && App.game.Player3 != "" && App.game.PlayerQuit3 == false) { App.game.PointsPlayer3++; } if (App.playerNum != 4 && App.game.Player4 != "" && App.game.PlayerQuit4 == false) { App.game.PointsPlayer4++; } try { await gameTable.UpdateAsync(App.game); } catch (System.Net.Http.HttpRequestException ex) { ContentDialog deleteFileDialog = new ContentDialog { FontSize = 10, Title = "Network Error", PrimaryButtonText = "Home" }; ContentDialogResult result = await deleteFileDialog.ShowAsync(); this.Frame.Navigate(typeof(ServerMenuPage)); } this.Frame.Navigate(typeof(LostPage)); } else if (readChar == 'w') // readChar=='w' { var PlayMusic = new MediaElement(); StorageFolder Folder = Windows.ApplicationModel.Package.Current.InstalledLocation; Folder = await Folder.GetFolderAsync("Sound"); StorageFile sf = await Folder.GetFileAsync("win.mp3"); PlayMusic.SetSource(await sf.OpenAsync(FileAccessMode.Read), sf.ContentType); PlayMusic.Play(); this.Frame.Navigate(typeof(WinPage)); } readChar = 'a'; } } // Catch exception HRESULT_FROM_WIN32(ERROR_OPERATION_ABORTED). catch (Exception ex) when((uint)ex.HResult == 0x800703E3) { Debug.Write("Client Disconnected Successfully"); //break; } App.btRxStarted = false; }
private async void ButtonQuit_Click(object sender, RoutedEventArgs e) { ContentDialog deleteFileDialog = new ContentDialog { Title = "Are you sure you want to quit the game?", PrimaryButtonText = "Quit", SecondaryButtonText = "Cancel" }; ContentDialogResult result = await deleteFileDialog.ShowAsync(); // Delete the file if the user clicked the primary button. /// Otherwise, do nothing. if (result == ContentDialogResult.Primary) { App.enableX = false; App.playing = false; var n = App._btWriter.WriteString("q\n"); await App._btWriter.StoreAsync(); try { App.game = await gameTable.LookupAsync(App.gameID); } catch (System.Net.Http.HttpRequestException ex) { ContentDialog deleteFileDialog2 = new ContentDialog { FontSize = 10, Title = "Network Error", PrimaryButtonText = "Home" }; ContentDialogResult result2 = await deleteFileDialog.ShowAsync(); this.Frame.Navigate(typeof(ServerMenuPage)); } switch (App.dataServiceDevice.Name) { case "LedP1": try { var p1 = await playersTable.LookupAsync(App.game.Player1); p1.Score += App.game.PointsPlayer1; p1.GamesPlayed++; await playersTable.UpdateAsync(p1); } catch (MobileServiceInvalidOperationException ex) { var p1 = new PlayerItem { Id = App.game.Player1, Score = App.game.PointsPlayer1, GamesPlayed = 1 }; await playersTable.InsertAsync(p1); } catch (System.Net.Http.HttpRequestException ex) { ContentDialog deleteFileDialog2 = new ContentDialog { FontSize = 10, Title = "Network Error", PrimaryButtonText = "Home" }; ContentDialogResult result2 = await deleteFileDialog.ShowAsync(); this.Frame.Navigate(typeof(ServerMenuPage)); } break; case "LedP2": try { var p2 = await playersTable.LookupAsync(App.game.Player2); p2.Score += App.game.PointsPlayer2; p2.GamesPlayed++; await playersTable.UpdateAsync(p2); } catch (MobileServiceInvalidOperationException ex) { var p2 = new PlayerItem { Id = App.game.Player2, Score = App.game.PointsPlayer2, GamesPlayed = 1 }; await playersTable.InsertAsync(p2); } catch (System.Net.Http.HttpRequestException ex) { ContentDialog deleteFileDialog2 = new ContentDialog { FontSize = 10, Title = "Network Error", PrimaryButtonText = "Home" }; ContentDialogResult result2 = await deleteFileDialog.ShowAsync(); this.Frame.Navigate(typeof(ServerMenuPage)); } break; case "LedP3": try { var p3 = await playersTable.LookupAsync(App.game.Player3); p3.Score += App.game.PointsPlayer3; p3.GamesPlayed++; await playersTable.UpdateAsync(p3); } catch (MobileServiceInvalidOperationException ex) { var p3 = new PlayerItem { Id = App.game.Player3, Score = App.game.PointsPlayer3, GamesPlayed = 1 }; await playersTable.InsertAsync(p3); } catch (System.Net.Http.HttpRequestException ex) { ContentDialog deleteFileDialog2 = new ContentDialog { FontSize = 10, Title = "Network Error", PrimaryButtonText = "Home" }; ContentDialogResult result2 = await deleteFileDialog.ShowAsync(); this.Frame.Navigate(typeof(ServerMenuPage)); } break; case "LedP4": try { var p4 = await playersTable.LookupAsync(App.game.Player4); p4.Score += App.game.PointsPlayer4; p4.GamesPlayed++; await playersTable.UpdateAsync(p4); } catch (MobileServiceInvalidOperationException ex) { var p4 = new PlayerItem { Id = App.game.Player4, Score = App.game.PointsPlayer4, GamesPlayed = 1 }; await playersTable.InsertAsync(p4); } catch (System.Net.Http.HttpRequestException ex) { ContentDialog deleteFileDialog2 = new ContentDialog { FontSize = 10, Title = "Network Error", PrimaryButtonText = "Home" }; ContentDialogResult result2 = await deleteFileDialog.ShowAsync(); this.Frame.Navigate(typeof(ServerMenuPage)); } break; } try { App.game = await gameTable.LookupAsync(App.gameID); } catch (System.Net.Http.HttpRequestException ex) { ContentDialog deleteFileDialog2 = new ContentDialog { FontSize = 10, Title = "Network Error", PrimaryButtonText = "Home" }; ContentDialogResult result2 = await deleteFileDialog.ShowAsync(); this.Frame.Navigate(typeof(ServerMenuPage)); } switch (App.dataServiceDevice.Name) { case "LedP1": App.game.PlayerQuit1 = true; break; case "LedP2": App.game.PlayerQuit2 = true; break; case "LedP3": App.game.PlayerQuit3 = true; break; case "LedP4": App.game.PlayerQuit4 = true; break; } switch (App.game.PlayersNum) { case 1: if (App.game.PlayerQuit1) { App.game.Complete = true; } break; case 2: if (App.game.PlayerQuit1 && App.game.PlayerQuit2) { App.game.Complete = true; } break; case 3: if (App.game.PlayerQuit1 && App.game.PlayerQuit2 && App.game.PlayerQuit3) { App.game.Complete = true; } break; case 4: if (App.game.PlayerQuit1 && App.game.PlayerQuit2 && App.game.PlayerQuit3 && App.game.PlayerQuit4) { App.game.Complete = true; } break; } try { await gameTable.UpdateAsync(App.game); } catch (System.Net.Http.HttpRequestException ex) { ContentDialog deleteFileDialog2 = new ContentDialog { FontSize = 10, Title = "Network Error", PrimaryButtonText = "Home" }; ContentDialogResult result2 = await deleteFileDialog.ShowAsync(); this.Frame.Navigate(typeof(ServerMenuPage)); } this.Frame.Navigate(typeof(ServerMenuPage)); } else { } }
private async void buttonGuardar_Click(object sender, RoutedEventArgs e) { if (radioButtonEditar.IsChecked == true) { int validar = await validarCampos(); if (validar == 1) { //Actualizar registro if (comboBoxIdTecnicoEditar.SelectedItem != null) { string idTecnico; object selectedItem = comboBoxIdTecnicoEditar.SelectedValue.ToString(); idTecnico = selectedItem.ToString(); var dialog = new MessageDialog("¿Esta seguro de modificar al usuario?"); dialog.Title = "¿Esta seguro?"; dialog.Commands.Add(new UICommand { Label = "Si", Id = 0 }); dialog.Commands.Add(new UICommand { Label = "No", Id = 1 }); var result = await dialog.ShowAsync(); if ((int)result.Id == 0) { try { IMobileServiceTableQuery <Usuario> query = UsuariosTable.Where(Usuario => Usuario.id == idTecnico); var res = await query.ToListAsync(); var item = res.First(); string idActualizar = item.id; JObject update = new JObject(); update.Add("id", idActualizar); update.Add("Nombre", textBoxNombre.Text); update.Add("APaterno", textBoxAPatrno.Text); update.Add("AMaterno", textBoxAMaterno.Text); update.Add("Contrasena", passwordBox.Password); update.Add("Telefono", textBoxTelefono.Text); update.Add("Correo", textBoxCorreo.Text); update.Add("Direccion", textBoxDireccion.Text); update.Add("FechaNacimiento", dpFechaNac.Date); var inserted = await UsuariosTable.UpdateAsync(update); //verificar si se modifico } catch (MobileServiceInvalidOperationException ex) { exception = ex; } if (exception != null) { await new MessageDialog(exception.Message, "Error!").ShowAsync(); } else { MessageDialog mensaje = new MessageDialog("Se actualizo correctamente.", "Actualización correcta"); await mensaje.ShowAsync(); limpiarTexBoxRegistroEditar(); disableTexBox(); radioButtonEditar.IsChecked = false; } } } } } else if (radioButtonRegistro.IsChecked == true) { int validar = await validarCampos(); if (validar == 1) { try { /*IMobileServiceTableQuery<Tecnicos> query = UsuariosTable.Select(Usuario => Usuario); * var res = await query.ToListAsync(); * int aux = res.Count; * int contador = aux++;*/ //string contadorInsert = contador.ToString(); JObject jo = new JObject(); jo.Add("id", textBoxNombreUsuario.Text); jo.Add("Contrasena", passwordBox.Password); jo.Add("Nombre", textBoxNombre.Text); jo.Add("APaterno", textBoxAPatrno.Text); jo.Add("AMaterno", textBoxAMaterno.Text); jo.Add("fechaNacimiento", dpFechaNac.Date); jo.Add("Telefono", textBoxTelefono.Text); jo.Add("Correo", textBoxCorreo.Text); jo.Add("Direccion", textBoxDireccion.Text); jo.Add("Tipo", "Tecnico"); var inserted = await UsuariosTable.InsertAsync(jo); } catch (MobileServiceInvalidOperationException ex) { exception = ex; } if (exception != null) { await new MessageDialog(exception.Message, "Error!").ShowAsync(); } else { MessageDialog mensaje = new MessageDialog("Se guardo correctamente la información.", "Se guardo correctamente"); await mensaje.ShowAsync(); limpiarTexBoxRegistroEditar(); disableTexBox(); radioButtonRegistro.IsChecked = false; } } } }
public async Task UpdateUserAsync(Users user) { await userTable.UpdateAsync(user); }
public static async Task UpdateData(Employer employer) { await employerTable.UpdateAsync(employer); }
public async Task AsyncTableOperationsWithStringIdAgainstIntegerIdTable() { await EnsureEmptyTableAsync <ToDoWithIntId>(); IMobileServiceTable <ToDoWithIntId> table = GetClient().GetTable <ToDoWithIntId>(); List <ToDoWithIntId> integerIdItems = new List <ToDoWithIntId>(); for (var i = 0; i < 10; i++) { ToDoWithIntId item = new ToDoWithIntId() { String = i.ToString() }; await table.InsertAsync(item); integerIdItems.Add(item); } string[] testIdData = IdTestData.ValidStringIds.ToArray(); IMobileServiceTable <ToDoWithStringIdAgainstIntIdTable> stringIdTable = GetClient().GetTable <ToDoWithStringIdAgainstIntIdTable>(); foreach (string testId in testIdData) { // Filter Exception exception = null; try { IEnumerable <ToDoWithStringIdAgainstIntIdTable> results = await stringIdTable.Where(p => p.Id == testId).ToEnumerableAsync(); ToDoWithStringIdAgainstIntIdTable[] items = results.ToArray(); } catch (Exception e) { exception = e; } Assert.IsNotNull(exception); Assert.IsTrue(exception.Message.Contains("Bad request")); // Refresh exception = null; try { ToDoWithStringIdAgainstIntIdTable item = new ToDoWithStringIdAgainstIntIdTable() { Id = testId, String = "Hey!" }; await stringIdTable.RefreshAsync(item); } catch (Exception e) { exception = e; } Assert.IsNotNull(exception); Assert.IsTrue(exception.Message.Contains("Bad request")); // Insert exception = null; try { ToDoWithStringIdAgainstIntIdTable item = new ToDoWithStringIdAgainstIntIdTable() { Id = testId, String = "Hey!" }; await stringIdTable.InsertAsync(item); } catch (Exception e) { exception = e; } Assert.IsNotNull(exception); Assert.IsTrue(exception.Message.Contains("Error: A value cannot be specified for property 'id'")); // Lookup exception = null; try { await stringIdTable.LookupAsync(testId); } catch (Exception e) { exception = e; } Assert.IsNotNull(exception); Assert.IsTrue(exception.Message.Contains("Error: The value specified for 'id' must be a number.")); // Update exception = null; try { ToDoWithStringIdAgainstIntIdTable item = new ToDoWithStringIdAgainstIntIdTable() { Id = testId, String = "Hey!" }; await stringIdTable.UpdateAsync(item); } catch (Exception e) { exception = e; } Assert.IsNotNull(exception); Assert.IsTrue(exception.Message.Contains("Error: The value specified for 'id' must be a number.")); // Delete exception = null; try { ToDoWithStringIdAgainstIntIdTable item = new ToDoWithStringIdAgainstIntIdTable() { Id = testId, String = "Hey!" }; await stringIdTable.DeleteAsync(item); } catch (Exception e) { exception = e; } Assert.IsNotNull(exception); Assert.IsTrue(exception.Message.Contains("Error: The value specified for 'id' must be a number.")); } foreach (ToDoWithIntId integerIdItem in integerIdItems) { await table.DeleteAsync(integerIdItem); } }
public static async Task UpdateData(Stock stock) { await stockTable.UpdateAsync(stock); }
public async void onBookingClick() { var hrsText = FindViewById <EditText>(Resource.Id.input_hr); var plateNoText = FindViewById <EditText>(Resource.Id.input_car_plate_number); var locationText = FindViewById <TextView>(Resource.Id.parking_area_name); string hrsRequested = hrsText.Text; string vehicleNo = plateNoText.Text; if (!String.IsNullOrEmpty(hrsRequested) || !String.IsNullOrEmpty(vehicleNo)) { int totalParkingAmount = 3 * Convert.ToInt32(hrsText.Text); wallet.Balance = "0"; //Check if wallet has enough balance IMobileServiceTable <Wallet> walletData = client.GetTable <Wallet>(); //Getting the Wallet details from the Database List <Wallet> currentBalance = await walletData.Where (item => item.Email == client.CurrentUser.UserId).ToListAsync(); if (currentBalance.Count > 0) { wallet = currentBalance[0]; Android.App.AlertDialog.Builder confirmAlert = new Android.App.AlertDialog.Builder(this); confirmAlert.SetTitle("Confirm Payment"); confirmAlert.SetMessage("Wallet Balance: " + wallet.Balance + "\n" + "" + "\n" + "Charge Per Hour: " + "RM 3.00" + "\n" + "Hours Reserving: " + hrsText.Text + "\n" + "Total Payment: " + "RM " + totalParkingAmount + "\n" + "" + "\n" + "** penalty will be issued when hours are exceeded."); confirmAlert.SetPositiveButton("Yes", async(senderAlert, args) => { if (Convert.ToInt32(wallet.Balance) >= totalParkingAmount) { var parkingDialog = ProgressDialog.Show(this, "Please wait...", "Confirming your parking...", true); parking.Email = user.Email; parking.LocationName = locationText.Text; parking.ChargePerHour = 3; parking.ParkedHours = Convert.ToInt32(hrsText.Text); parking.CarPlateNumber = plateNoText.Text; parking.TotaAmount = totalParkingAmount; //Initializing the parking table IMobileServiceTable <Parking> parkingTable = client.GetTable <Parking>(); //Inserting new parking to the Database await parkingTable.InsertAsync(parking); //Update the wallet balance wallet.Balance = Convert.ToString(Convert.ToInt32(wallet.Balance) - totalParkingAmount); parking = await GetLastParking(); var extraParameters = new Dictionary <string, string>(); extraParameters.Add("userId", user.Id); extraParameters.Add("type", "parking"); extraParameters.Add("parkingId", parking.Id); await walletData.UpdateAsync(wallet, extraParameters); Android.App.AlertDialog.Builder alertSuccess = new Android.App.AlertDialog.Builder(this); alertSuccess.SetTitle("Parking Area"); alertSuccess.SetMessage("Payment is successful"); alertSuccess.SetPositiveButton("Ok", (senderAlertSucces, argsSuccess) => { RefreshActivity(); }); Dialog dialogSuccess = alertSuccess.Create(); dialogSuccess.Show(); } else { GoToTopUpWallet(Convert.ToInt32(wallet.Balance), totalParkingAmount); } }); confirmAlert.SetNegativeButton("Cancel", (senderAlert, args) => { Toast.MakeText(this, "Cancelled!", ToastLength.Short).Show(); }); Dialog dialog = confirmAlert.Create(); dialog.Show(); } else { GoToTopUpWallet(Convert.ToInt32(wallet.Balance), totalParkingAmount); } } else { Android.App.AlertDialog.Builder alertEmpty = new Android.App.AlertDialog.Builder(this); alertEmpty.SetTitle("Parking Area"); alertEmpty.SetMessage("Fill in the required fields"); alertEmpty.SetPositiveButton("Ok", (senderAlertSucces, argsSuccess) => { }); Dialog dialogSuccess = alertEmpty.Create(); dialogSuccess.Show(); } }
private async void CheckNetworkAvailability() { online = NetworkInterface.NetworkInterfaceType.ToString()!="None"; if (online) { MobileService = new MobileServiceClient( "https://shopappdata.azure-mobile.net/", "dkwwuiuHYYQwbozjKaWRJYYpEiTjFt73" ); itemTable = MobileService.GetTable<Items>(); buffer = XmlTaskService.GetTasks("buffer.xml"); foreach (Items buffitem in buffer) { try { await itemTable.InsertAsync(buffitem); XmlTaskService.CreateTask(buffitem, "tasks.xml"); } catch { } } XmlTaskService.DeleteAllTasks("buffer.xml"); buffer.Clear(); buffer = XmlTaskService.GetTasks("checked.xml"); foreach (Items buffitem in buffer) { Debug.WriteLine("Item is "); Debug.WriteLine(buffitem.Text) ; checked_item = XmlTaskService.GetTasksByText(buffitem.Text, "tasks.xml"); checked_item.shared = true; Debug.WriteLine("checked"); Debug.WriteLine(checked_item.Text); try { await itemTable.UpdateAsync(checked_item); } catch { } } XmlTaskService.DeleteAllTasks("checked.xml"); buffer.Clear(); buffer = XmlTaskService.GetTasks("delete.xml"); foreach (Items buffitem in buffer) { checked_item = XmlTaskService.GetTasksByText(buffitem.Text, "tasks.xml"); try { await itemTable.DeleteAsync(checked_item); } catch { } } XmlTaskService.DeleteAllTasks("delete.xml"); buffer.Clear(); } }
public async Task UpdateAsync(DataItem item) { await m_Table.UpdateAsync(item); }
public async void AcquirePushChannel() { CurrentChannel = HttpNotificationChannel.Find("MyPushChannel"); if (CurrentChannel == null) { CurrentChannel = new HttpNotificationChannel("MyPushChannel"); CurrentChannel.Open(); CurrentChannel.BindToShellTile(); } var uri = CurrentChannel.ChannelUri.ToString(); userTable = MobileService.GetTable<Users>(); if (settings.Contains("Pnumber")) { Users up = new Users(); up.uri = uri; up.Id = user_id; up.Name = user_name; up.Phone_no = pnumber; await userTable.UpdateAsync(up); } }
public async Task <T> UpdateItemAsync(T item) { await table.UpdateAsync(item); return(item); }
public async Task AsyncTableOperationsWithAllSystemProperties() { await EnsureEmptyTableAsync <ToDoWithSystemPropertiesType>(); string id = "an id"; IMobileServiceTable <ToDoWithSystemPropertiesType> table = GetClient().GetTable <ToDoWithSystemPropertiesType>(); ToDoWithSystemPropertiesType item = new ToDoWithSystemPropertiesType() { Id = id, String = "a value" }; await table.InsertAsync(item); Assert.IsNotNull(item.CreatedAt); Assert.IsNotNull(item.UpdatedAt); Assert.IsNotNull(item.Version); // Read IEnumerable <ToDoWithSystemPropertiesType> results = await table.ReadAsync(); ToDoWithSystemPropertiesType[] items = results.ToArray(); Assert.AreEqual(1, items.Count()); Assert.IsNotNull(items[0].CreatedAt); Assert.IsNotNull(items[0].UpdatedAt); Assert.IsNotNull(items[0].Version); // Filter against version results = await table.Where(i => i.Version == items[0].Version).ToEnumerableAsync(); ToDoWithSystemPropertiesType[] filterItems = results.ToArray(); Assert.AreEqual(1, items.Count()); Assert.AreEqual(filterItems[0].CreatedAt, items[0].CreatedAt); Assert.AreEqual(filterItems[0].UpdatedAt, items[0].UpdatedAt); Assert.AreEqual(filterItems[0].Version, items[0].Version); // Filter against createdAt results = await table.Where(i => i.CreatedAt == items[0].CreatedAt).ToEnumerableAsync(); filterItems = results.ToArray(); Assert.AreEqual(1, items.Count()); Assert.AreEqual(filterItems[0].CreatedAt, items[0].CreatedAt); Assert.AreEqual(filterItems[0].UpdatedAt, items[0].UpdatedAt); Assert.AreEqual(filterItems[0].Version, items[0].Version); // Filter against updatedAt results = await table.Where(i => i.UpdatedAt == items[0].UpdatedAt).ToEnumerableAsync(); filterItems = results.ToArray(); Assert.AreEqual(1, items.Count()); Assert.AreEqual(filterItems[0].CreatedAt, items[0].CreatedAt); Assert.AreEqual(filterItems[0].UpdatedAt, items[0].UpdatedAt); Assert.AreEqual(filterItems[0].Version, items[0].Version); // Projection var projectedResults = await table.Select(i => new { XId = i.Id, XCreatedAt = i.CreatedAt, XUpdatedAt = i.UpdatedAt, XVersion = i.Version }).ToEnumerableAsync(); var projectedItems = projectedResults.ToArray(); Assert.AreEqual(1, projectedResults.Count()); Assert.AreEqual(projectedItems[0].XId, items[0].Id); Assert.AreEqual(projectedItems[0].XCreatedAt, items[0].CreatedAt); Assert.AreEqual(projectedItems[0].XUpdatedAt, items[0].UpdatedAt); Assert.AreEqual(projectedItems[0].XVersion, items[0].Version); // Lookup item = await table.LookupAsync(id); Assert.AreEqual(id, item.Id); Assert.AreEqual(item.Id, items[0].Id); Assert.AreEqual(item.CreatedAt, items[0].CreatedAt); Assert.AreEqual(item.UpdatedAt, items[0].UpdatedAt); Assert.AreEqual(item.Version, items[0].Version); // Refresh item = new ToDoWithSystemPropertiesType() { Id = id }; await table.RefreshAsync(item); Assert.AreEqual(id, item.Id); Assert.AreEqual(item.Id, items[0].Id); Assert.AreEqual(item.CreatedAt, items[0].CreatedAt); Assert.AreEqual(item.UpdatedAt, items[0].UpdatedAt); Assert.AreEqual(item.Version, items[0].Version); // Update item.String = "Hello!"; await table.UpdateAsync(item); Assert.AreEqual(item.Id, items[0].Id); Assert.AreEqual(item.CreatedAt, items[0].CreatedAt); Assert.IsTrue(item.UpdatedAt >= items[0].UpdatedAt); Assert.IsNotNull(item.Version); Assert.AreNotEqual(item.Version, items[0].Version); // Read Again results = await table.ReadAsync(); items = results.ToArray(); Assert.AreEqual(id, item.Id); Assert.AreEqual(item.Id, items[0].Id); Assert.AreEqual(item.CreatedAt, items[0].CreatedAt); Assert.AreEqual(item.UpdatedAt, items[0].UpdatedAt); Assert.AreEqual(item.Version, items[0].Version); await table.DeleteAsync(item); }
public async Task UpdateAsyncWitMergeConflict_Generic() { await EnsureEmptyTableAsync <RoundTripTableItemWithSystemPropertiesType>(); string id = Guid.NewGuid().ToString(); IMobileServiceTable <RoundTripTableItemWithSystemPropertiesType> table = GetClient().GetTable <RoundTripTableItemWithSystemPropertiesType>(); RoundTripTableItemWithSystemPropertiesType item = new RoundTripTableItemWithSystemPropertiesType() { Id = id, Name = "a value" }; await table.InsertAsync(item); Assert.IsNotNull(item.CreatedAt); Assert.IsNotNull(item.UpdatedAt); Assert.IsNotNull(item.Version); string version = item.Version; // Update item.Name = "Hello!"; await table.UpdateAsync(item); Assert.IsNotNull(item.Version); Assert.AreNotEqual(item.Version, version); string newVersion = item.Version; // Update again but with the original version item.Version = version; item.Name = "But wait!"; MobileServicePreconditionFailedException <RoundTripTableItemWithSystemPropertiesType> expectedException = null; try { await table.UpdateAsync(item); } catch (MobileServicePreconditionFailedException <RoundTripTableItemWithSystemPropertiesType> exception) { expectedException = exception; } Assert.IsNotNull(expectedException); Assert.AreEqual(expectedException.Response.StatusCode, HttpStatusCode.PreconditionFailed); Assert.IsNotNull(expectedException.Item); string serverVersion = expectedException.Item.Version; string stringValue = expectedException.Item.Name; Assert.AreEqual(newVersion, serverVersion); Assert.AreEqual(stringValue, "Hello!"); // Update one last time with the version from the server item.Version = serverVersion; await table.UpdateAsync(item); Assert.IsNotNull(item.Version); Assert.AreEqual(item.Name, "But wait!"); Assert.AreNotEqual(item.Version, serverVersion); await table.DeleteAsync(item); }
public static async Task UpdateData(StockPriceHistory stockPriceHistory) { await stockPriceHistoryTable.UpdateAsync(stockPriceHistory); }
public async void ObrisiKorisnikaAsync(object parametar) { if (Kor == null) { return; } IMobileServiceTable <Korisnici> usersTable = App.MobileService.GetTable <Korisnici>(); IMobileServiceTable <Projekti> projectsTable = App.MobileService.GetTable <Projekti>(); for (int i = 0; i < BatNet.Projekti.Count; i++) { if (BatNet.Projekti.ElementAt(i).Autor.KorisnickoIme == Kor.KorisnickoIme) { for (int j = 0; j < BatNet.Korisnici.Count; j++) { for (int k = 0; k < BatNet.Projekti.Count; k++) { if (BatNet.Projekti.ElementAt(k).ID1.Equals(Projekti.ElementAt(i).ID1)) { BatNet.Korisnici.ElementAt(j).Projekti.RemoveAt(k); } } } List <Projekti> projekat = await projectsTable.Where(u => u.id == BatNet.Projekti.ElementAt(i).ID1).ToListAsync(); if (projekat.Count > 1) { Debug.WriteLine("Big mistake! Stahp!"); return; } projekat.ElementAt(0).obrisan = true; await projectsTable.UpdateAsync(projekat.ElementAt(0)); BatNet.Projekti.RemoveAt(i); } } for (int i = 0; i < BatNet.Korisnici.Count; i++) { if (BatNet.Korisnici.ElementAt(i).KorisnickoIme == Kor.KorisnickoIme) { List <Korisnici> korisnik = await usersTable.Where(u => u.id == Kor.ID.ToString()).ToListAsync(); if (korisnik.Count > 1) { Debug.WriteLine("Big mistake! Stahp!"); return; } korisnik.ElementAt(0).obrisan = true; await usersTable.UpdateAsync(korisnik.ElementAt(0)); Korisnici.Remove(Kor); BatNet.Korisnici.Remove(Kor); MessageDialog messageDialog = new MessageDialog("Korisnik obrisan!"); await messageDialog.ShowAsync(); break; } } }
public async Task AsyncTableOperationsWithAllSystemProperties() { await EnsureEmptyTableAsync <RoundTripTableItemWithSystemPropertiesType>(); string id = Guid.NewGuid().ToString(); IMobileServiceTable <RoundTripTableItemWithSystemPropertiesType> table = GetClient().GetTable <RoundTripTableItemWithSystemPropertiesType>(); RoundTripTableItemWithSystemPropertiesType item = new RoundTripTableItemWithSystemPropertiesType() { Id = id, Name = "a value" }; await table.InsertAsync(item); Assert.IsNotNull(item.CreatedAt); Assert.IsNotNull(item.UpdatedAt); Assert.IsNotNull(item.Version); // Read IEnumerable <RoundTripTableItemWithSystemPropertiesType> results = await table.ReadAsync(); RoundTripTableItemWithSystemPropertiesType[] items = results.ToArray(); Assert.AreEqual(1, items.Count()); Assert.IsNotNull(items[0].CreatedAt); Assert.IsNotNull(items[0].UpdatedAt); Assert.IsNotNull(items[0].Version); // Filter against version // BUG #1706815 (OData query for version field (string <--> byte[] mismatch) /* * results = await table.Where(i => i.Version == items[0].Version).ToEnumerableAsync(); * RoundTripTableItemWithSystemPropertiesType[] filterItems = results.ToArray(); * * Assert.AreEqual(1, items.Count()); * Assert.AreEqual(filterItems[0].CreatedAt, items[0].CreatedAt); * Assert.AreEqual(filterItems[0].UpdatedAt, items[0].UpdatedAt); * Assert.AreEqual(filterItems[0].Version, items[0].Version); * * // Filter against createdAt * results = await table.Where(i => i.CreatedAt == items[0].CreatedAt).ToEnumerableAsync(); * RoundTripTableItemWithSystemPropertiesType[] filterItems = results.ToArray(); * * Assert.AreEqual(1, items.Count()); * Assert.AreEqual(filterItems[0].CreatedAt, items[0].CreatedAt); * Assert.AreEqual(filterItems[0].UpdatedAt, items[0].UpdatedAt); * Assert.AreEqual(filterItems[0].Version, items[0].Version); * * // Filter against updatedAt * results = await table.Where(i => i.UpdatedAt == items[0].UpdatedAt).ToEnumerableAsync(); * filterItems = results.ToArray(); * * Assert.AreEqual(1, items.Count()); * Assert.AreEqual(filterItems[0].CreatedAt, items[0].CreatedAt); * Assert.AreEqual(filterItems[0].UpdatedAt, items[0].UpdatedAt); * Assert.AreEqual(filterItems[0].Version, items[0].Version); */ // Projection var projectedResults = await table.Select(i => new { XId = i.Id, XCreatedAt = i.CreatedAt, XUpdatedAt = i.UpdatedAt, XVersion = i.Version }).ToEnumerableAsync(); var projectedItems = projectedResults.ToArray(); Assert.AreEqual(1, projectedResults.Count()); Assert.AreEqual(projectedItems[0].XId, items[0].Id); Assert.AreEqual(projectedItems[0].XCreatedAt, items[0].CreatedAt); Assert.AreEqual(projectedItems[0].XUpdatedAt, items[0].UpdatedAt); Assert.AreEqual(projectedItems[0].XVersion, items[0].Version); // Lookup item = await table.LookupAsync(id); Assert.AreEqual(id, item.Id); Assert.AreEqual(item.Id, items[0].Id); Assert.AreEqual(item.CreatedAt, items[0].CreatedAt); Assert.AreEqual(item.UpdatedAt, items[0].UpdatedAt); Assert.AreEqual(item.Version, items[0].Version); // Refresh item = new RoundTripTableItemWithSystemPropertiesType() { Id = id }; await table.RefreshAsync(item); Assert.AreEqual(id, item.Id); Assert.AreEqual(item.Id, items[0].Id); Assert.AreEqual(item.CreatedAt, items[0].CreatedAt); Assert.AreEqual(item.UpdatedAt, items[0].UpdatedAt); Assert.AreEqual(item.Version, items[0].Version); // Update item.Name = "Hello!"; await table.UpdateAsync(item); Assert.AreEqual(item.Id, items[0].Id); Assert.AreEqual(item.CreatedAt, items[0].CreatedAt); Assert.IsTrue(item.UpdatedAt >= items[0].UpdatedAt); Assert.IsNotNull(item.Version); Assert.AreNotEqual(item.Version, items[0].Version); // Read Again results = await table.ReadAsync(); items = results.ToArray(); Assert.AreEqual(id, item.Id); Assert.AreEqual(item.Id, items[0].Id); Assert.AreEqual(item.CreatedAt, items[0].CreatedAt); Assert.AreEqual(item.UpdatedAt, items[0].UpdatedAt); Assert.AreEqual(item.Version, items[0].Version); await table.DeleteAsync(item); }
//update public async void actualizar(object sender, object args) { if (titulotxt.Text == null || descritxt.Text == null || personapic.Text == null || prioripic.Text == null || fechapick.Date == null || depentxt.Text == null || statuspic.Text == null) { await DisplayAlert("Alerta", "Te falta llenar algun campo para poder insertar el contacto ", "OK"); } else { var datos = new tabletareas { Titulo = titulotxt.Text, Description = descritxt.Text, Persona = personapic.Text, Prioridad = prioripic.Text, Fecha = fechapick.Date, Dependencia = depentxt.Text, Estatus = statuspic.Text }; IEnumerable <tabletareas> items = await tabla.ToEnumerableAsync(); string[] arreglo1 = new string[items.Count()]; string[] arreglo2 = new string[items.Count()]; string[] arreglo3 = new string[items.Count()]; string[] arreglo4 = new string[items.Count()]; string[] arreglo6 = new string[items.Count()]; DateTime[] arreglo5 = new DateTime[items.Count()]; int i = 0; foreach (var x in items) { arreglo1[i] = x.Titulo; arreglo2[i] = x.Persona; arreglo3[i] = x.Estatus; arreglo4[i] = x.Prioridad; arreglo5[i] = x.Fecha; arreglo6[i] = x.Description; if (x.Titulo == titulotxt.Text) { if (x.Persona != personapic.Text) { x.Persona = personapic.Text; } if (x.Description != descritxt.Text) { x.Description = descritxt.Text; } if (x.Estatus != statuspic.Text) { x.Estatus = statuspic.Text; } if (x.Prioridad != prioripic.Text) { x.Prioridad = prioripic.Text; } if (x.Fecha != fechapick.Date) { x.Fecha = fechapick.Date; } await tabla.UpdateAsync(x); await DisplayAlert("Alerta", "Tu contacto ha sido actualizado con exito ", "OK"); } } } }
private async void Buy_Click(object sender, RoutedEventArgs e) { //take rec.id to send in post with header id try { LoadingBar.IsIndeterminate = true; LoadingBar.Visibility = Visibility.Visible; var test = sender as Button; var test2 = test.Parent as Grid; var test3 = test2.Children[3] as TextBlock; var test5 = test2.Children[1] as TextBlock; string hello = test5.Text.Substring(7); items2 = await Table2.Where(User => User.username == testlol).ToCollectionAsync(); User a = items2[0]; if (!a.purchases.Contains(rec.Id + "." + test3.Text) && !a.purchases.Contains(rec.Id + ".full")) { if (a.wallet > int.Parse(hello)) { a.purchases += rec.Id + "." + test3.Text + ","; a.wallet = a.wallet - int.Parse(hello); await Table2.UpdateAsync(a); items3 = await Table3.Where(Author => Author.books.Contains(rec.Id)).ToCollectionAsync(); Author c = items3[0]; c.wallet += int.Parse(hello); await Table3.UpdateAsync(c); items = await Table.Where(Chapter => Chapter.Id == test3.Text).ToCollectionAsync(); Chapter b = items[0]; b.downloads++; await Table.UpdateAsync(b); LoadingBar.Visibility = Visibility.Collapsed; Windows.UI.Popups.MessageDialog mess = new Windows.UI.Popups.MessageDialog("Purchase successfull! Download the file from My purchase section"); await mess.ShowAsync(); Frame.Navigate(typeof(Purchased)); } else { LoadingBar.Visibility = Visibility.Collapsed; Windows.UI.Popups.MessageDialog mess = new Windows.UI.Popups.MessageDialog("You have insufficient funds for this!"); await mess.ShowAsync(); } } else { LoadingBar.Visibility = Visibility.Collapsed; Windows.UI.Popups.MessageDialog mess = new Windows.UI.Popups.MessageDialog("You have already purchased this!"); await mess.ShowAsync(); } } catch (Exception) { MessageDialog msgbox = new MessageDialog("Something is not right try again"); await msgbox.ShowAsync(); LoadingBar.Visibility = Visibility.Collapsed; } }