private async void PerformUserLogin(object sender, System.Windows.Input.GestureEventArgs e) { username = userName.Text; phoneNo = userPhone.Text; if (MainPage.online == true) { Users user = new Users(); user.Name = username; user.Phone_no = phoneNo; user.uri = "uri here"; MobileService = new MobileServiceClient( "https://shopappdata.azure-mobile.net/", "dkwwuiuHYYQwbozjKaWRJYYpEiTjFt73" ); userTable = MobileService.GetTable<Users>(); await userTable.InsertAsync(user); user_id = user.Id; MainPage.settings.Add("id", user_id); MainPage.settings.Add("Pnumber", phoneNo); MainPage.settings.Add("name", username); } else { // Prompt } // TODO: send this username and phoneno. to be added into the database NavigationService.GoBack(); }
public async Task InsertarEntidad(string direccionCorreo, string reto, string androidId) { _torneoItemTable = _clienteServicio.GetTable <TorneoItem>(); await _torneoItemTable.InsertAsync(new TorneoItem { Email = direccionCorreo, Reto = reto, DeviceId = androidId }); }
private async Task InsertTodoItem(TodoItem todoItem) { // This code inserts a new TodoItem into the database. When the operation completes // and Mobile Services has assigned an Id, the item is added to the CollectionView await todoTable.InsertAsync(todoItem); items.Add(todoItem); //await SyncAsync(); // offline sync }
public async Task InsertTodoItemAsync(MonkeyItem monkeyItem) { try { // This code inserts a new MonkeyItem into the database. When the operation completes // and Mobile Services has assigned an Id, the item is added to the CollectionView await monkeyTable.InsertAsync(monkeyItem); } catch (MobileServiceInvalidOperationException e) { Console.Error.WriteLine(@"ERROR {0}", e.Response); } }
private async Task InsertTournament(Tournament tournament) { // This code inserts a new Tournament into the database. When the operation completes // and Mobile Apps has assigned an Id, the item is added to the CollectionView await tournamentsTable.InsertAsync(tournament); tournaments.Add(tournament); //await App.MobileService.SyncContext.PushAsync(); // offline sync }
public async Task insert(T row) { // This code inserts a new TodoItem into the database. When the operation completes // and Mobile Services has assigned an Id, the item is added to the CollectionView //await refresh(); await table.InsertAsync(row); serviceCollection.Add(row); //await SyncAsync(); // offline sync }
public async Task InsertItem(Event item) { if (item.Id == null) { item.Id = Guid.NewGuid().ToString(); } await EventTable.InsertAsync(item); await LoadData(); }
public Task InsertExpenseAsync(Expense expense) { if (expenseTable == null) { expense.UserId = UserId; return(Task.FromResult <object>(null)); } return(expenseTable.InsertAsync(expense)); }
public async Task OrderingReadAsyncWithValidStringIdAgainstStringIdTable() { await EnsureEmptyTableAsync <ToDoWithStringId>(); string[] testIdData = new string[] { "a", "b", "C", "_A", "_B", "_C", "1", "2", "3" }; IMobileServiceTable <ToDoWithStringId> table = GetClient().GetTable <ToDoWithStringId>(); foreach (string testId in testIdData) { ToDoWithStringId item = new ToDoWithStringId() { Id = testId, String = "Hey" }; await table.InsertAsync(item); } IEnumerable <ToDoWithStringId> results = await table.OrderBy(p => p.Id).ToEnumerableAsync(); ToDoWithStringId[] items = results.ToArray(); Assert.AreEqual(9, items.Count()); Assert.AreEqual("_A", items[0].Id); Assert.AreEqual("_B", items[1].Id); Assert.AreEqual("_C", items[2].Id); Assert.AreEqual("1", items[3].Id); Assert.AreEqual("2", items[4].Id); Assert.AreEqual("3", items[5].Id); Assert.AreEqual("a", items[6].Id); Assert.AreEqual("b", items[7].Id); Assert.AreEqual("C", items[8].Id); results = await table.OrderByDescending(p => p.Id).ToEnumerableAsync(); items = results.ToArray(); Assert.AreEqual(9, items.Count()); Assert.AreEqual("_A", items[8].Id); Assert.AreEqual("_B", items[7].Id); Assert.AreEqual("_C", items[6].Id); Assert.AreEqual("1", items[5].Id); Assert.AreEqual("2", items[4].Id); Assert.AreEqual("3", items[3].Id); Assert.AreEqual("a", items[2].Id); Assert.AreEqual("b", items[1].Id); Assert.AreEqual("C", items[0].Id); foreach (string testId in testIdData) { ToDoWithStringId item = new ToDoWithStringId() { Id = testId }; await table.DeleteAsync(item); } }
private async void potvrda_Click(object sender, RoutedEventArgs e) { IMobileServiceTable <Models.Radnik> tabelaRadnici = App.MobileService.GetTable <Models.Radnik>(); string ime = ime1.Text; string prezime = prezime2.Text; object Temp = pozicija2.SelectedItem; string pozicija = Temp.ToString(); string plata = plata2.Text; string korisnicko = korisnicko2.Text; string lozinka = lozinka2.Password.ToString(); string potvrda = potvrdalozinka2.Password.ToString(); //DateTime datum = dat2.get; greska1.Foreground = new SolidColorBrush(Colors.Red); if (ime.Length == 0 || prezime.Length == 0 || pozicija.Length == 0 || plata.Length == 0 || korisnicko.Length == 0) { greska1.Text = "Morate popuniti sva polja!"; } else if (lozinka.Length <= 3) { greska1.Text = "Lozinka mora imati više od tri znaka!"; } else if (korisnicko.Length <= 3) { greska1.Text = "Korisničko ime mora imati više od tri znaka!"; } else if (!lozinka.Equals(potvrda)) { greska1.Text = "Lozinke se ne podudaraju!"; } else { greska1.Text = " "; Boolean b = await radnikvm.Registruj(lozinka, korisnicko, ime, prezime, pozicija, default(DateTime)); if (b) { // await showDialog4.ShowAsync(); // this.Frame.Navigate(typeof(PocetnaForma)); } ECopy.Models.Radnik novi = new ECopy.Models.Radnik(ime, prezime, korisnicko, lozinka, pozicija, float.Parse(plata), default(DateTime)); novi.id = 0; tabelaRadnici.InsertAsync(novi); MessageDialog showDialog = new MessageDialog("Uspješno ste se registrovali"); await showDialog.ShowAsync(); } }
async private void Oncontinueclicked(object sender, EventArgs e) { if (password.Text != string.Empty && password.Text != null) { var Departmntstrng = string.Empty; switch (department.SelectedIndex) { case 0: Departmntstrng = "cse"; break; case 1: Departmntstrng = "mae"; break; case 2: Departmntstrng = "ece"; break; } var studentin = new Modal.StudentsInfo { Num = rollno.Text, Name = name.Text, Department = Departmntstrng, Session = sessoin.Text, Dob = birthdate.Text, Phone = phone.Text, Email = email.Text, Password = password.Text, }; try { syncIndicator.IsRunning = true; syncIndicator.IsVisible = true; await table.InsertAsync(studentin); syncIndicator.IsVisible = false; syncIndicator.IsRunning = false; await DisplayAlert("Information", "Registered Successfully", "Ok"); await Navigation.PopModalAsync(); await Navigation.PushModalAsync(new SigninPage()); } catch (Exception exp) { //mainstack.IsVisible = true; syncIndicator.IsRunning = false; syncIndicator.IsVisible = false; await DisplayAlert("!! Registration Fail", "Please check your internet connection.", "ok"); } finally { //mainstack.IsVisible = true; } } else { await DisplayAlert("!! Registration Fail", "Please enter full details", "ok"); } }
public async Task <LoginResult> ChangePassword(String username, String oldPassword, string newPassword) { IMobileServiceTable accounts = this.GetTable("logins"); LoginResult loginResults = new LoginResult(); JObject credentialsObj = JObject.FromObject(new { username = username, password = oldPassword, } ); try { Dictionary <String, String> parameters = new Dictionary <String, String>(); parameters.Add("login", "true"); Task <JToken> x = accounts.InsertAsync(credentialsObj, parameters); JToken jt = await x; string token = jt.Value <String>("token"); string userid = jt.Value <String>("userId").Replace(AUD_HEADER, ""); //call the update function for this user JObject updateObj = JObject.FromObject(new { id = userid, password = newPassword, } ); x = accounts.UpdateAsync(updateObj); jt = await x; token = jt.Value <String>("token"); userid = jt.Value <String>("userId"); loginResults.Success = true; loginResults.UserId = userid; loginResults.UserToken = token; loginResults.UserName = username; } catch (Exception ex) { loginResults.Success = false; loginResults.ErrorString = ex.Message; } return(loginResults); }
public void PostComments() { MobileServiceClient client = GetClient(); IMobileServiceTable <BlogPost> postTable = client.GetTable <BlogPost>(); IMobileServiceTable <BlogComment> commentTable = client.GetTable <BlogComment>(); // Add a few posts and a comment //Log("Adding posts"); BlogPost post = new BlogPost { Title = "Windows 8" }; postTable.InsertAsync(post).WaitOrFail(Timeout); BlogPost highlight = new BlogPost { Title = "ZUMO" }; postTable.InsertAsync(highlight).WaitOrFail(Timeout); commentTable.InsertAsync(new BlogComment { BlogPostId = post.Id, UserName = "******", Text = "Beta runs great" }).Wait(Timeout); commentTable.InsertAsync(new BlogComment { BlogPostId = highlight.Id, UserName = "******", Text = "Whooooo" }).WaitOrFail(Timeout); Assert.AreEqual(2, postTable.Where(p => p.Id >= post.Id).ToListAsync().WaitOrFail(Timeout).Count); // Navigate to the first post and add a comment //Log("Adding comment to first post"); BlogPost first = postTable.LookupAsync(post.Id).WaitOrFail(Timeout); Assert.AreEqual("Windows 8", first.Title); BlogComment opinion = new BlogComment { BlogPostId = first.Id, Text = "Can't wait" }; commentTable.InsertAsync(opinion).WaitOrFail(Timeout); Assert.AreNotEqual(0, opinion.Id); }
public Content AddContent() { Content instance = new Content { Id = Guid.NewGuid().ToString() }; _contentTable.InsertAsync(instance); _items.Add(instance); return(instance); }
public async Task SaveTodoItemAsync(TodoItem todoItem) { if (todoItem.ID == null) { await todoTable.InsertAsync(todoItem); } else { await todoTable.UpdateAsync(todoItem); } }
public async Task SaveTaskAsync(UserInfo item) { if (item.UserIdentifier == null) { await _userInfoTable.InsertAsync(item); } else { await _userInfoTable.UpdateAsync(item); } }
public async Task SaveCarAsync(Cars car) { if (car.ID == null) { await carsTable.InsertAsync(car); } else { await carsTable.UpdateAsync(car); } }
public async Task addCiudadesAsync(Ciudades ciudad) { if (string.IsNullOrEmpty(ciudad.id)) { await _table.InsertAsync(ciudad); } else { await _table.UpdateAsync(ciudad); } }
public async Task SaveTodoItemAsync(TodoItem todoItem) { if (String.IsNullOrEmpty(todoItem.ID)) { await todoTable.InsertAsync(todoItem); } else { await todoTable.UpdateAsync(todoItem); } }
public async Task <bool> AddItemAsync(Member item) { if (item == null || !CrossConnectivity.Current.IsConnected) { return(false); } item.CreatedOn = DateTime.Now; await MemberTable.InsertAsync(item); return(!string.IsNullOrEmpty(item.Id)); }
public async Task InsertarEntidad(string direccionCorreo, string lab, string AndroidId) { _LabItemTable = clienteServicio.GetTable <LabItem>(); await _LabItemTable.InsertAsync(new LabItem { Email = direccionCorreo, Lab = lab, DeviceId = AndroidId }); }
public async Task SaveBudgetTransactionItemAsync(BudgetTransaction item) { if (item.Id == null) { await transactionTable.InsertAsync(item); } else { await transactionTable.UpdateAsync(item); } }
public async Task SaveTaskAsync(TodoItem item) { if (item.Id == null) { await todoTable.InsertAsync(item); } else { await todoTable.UpdateAsync(item); } }
public async Task PostCommentsWithDataContract() { MobileServiceClient client = GetClient(); IMobileServiceTable <DataContractBlogPost> postTable = client.GetTable <DataContractBlogPost>(); // Add a few posts and a comment Log("Adding posts"); DataContractBlogPost post = new DataContractBlogPost() { Title = "How DataContracts Work" }; await postTable.InsertAsync(post); DataContractBlogPost highlight = new DataContractBlogPost { Title = "Using the 'DataMember' attribute" }; await postTable.InsertAsync(highlight); Assert.AreEqual(2, (await postTable.Where(p => p.Id >= post.Id).ToListAsync()).Count); }
public async Task SaveTaskAsync(AccountInfo item, bool isNew) { if (isNew == true) { await accountTable.InsertAsync(item); } else { await accountTable.UpdateAsync(item); } }
//Saving a new Position public async Task SaveNewPositionAsync(Position position) { if (position.positionName == null) { await positionTable.InsertAsync(position); } else { await positionTable.UpdateAsync(position); } }
public async Task SaveTaskAsync(MainTable item) { if (item.Id == null) { await mainTable.InsertAsync(item); } else { await mainTable.UpdateAsync(item); } }
private async void potvrda_Click(object sender, RoutedEventArgs e) { IMobileServiceTable <Firma> tabelaFirma = App.MobileService.GetTable <Firma>(); string naziv = imefirmeBox.Text; string ime = ime1Box.Text; string prezime = prezimeBox.Text; string adresa = adresaBox.Text; string email = emailBox.Text; string korisnicko = imeBox.Text; string lozinka = sifraBox.Password.ToString(); string potvrda = potvrdasifrebox.Password.ToString(); string racun = racunBox.Text; greska1.Foreground = new SolidColorBrush(Colors.Red); if (naziv.Length == 0 || ime.Length == 0 || prezime.Length == 0 || adresa.Length == 0 || email.Length == 0 || korisnicko.Length == 0) { greska1.Text = "Morate popuniti sva polja!"; } else if (lozinka.Length <= 3) { greska1.Text = "Lozinka mora imati više od tri znaka!"; } else if (korisnicko.Length <= 3) { greska1.Text = "Korisničko ime mora imati više od tri znaka!"; } else if (!email.Contains("@") || !email.Contains(".")) { greska1.Text = "Neispravan format emaila!"; } else if (!lozinka.Equals(potvrda)) { greska1.Text = "Lozinke se ne podudaraju!"; } else if (!IsDigitsOnly(racun) || racun.Length <= 8) { greska1.Text = "Neispravan broj racuna!"; } else { greska1.Text = " "; Firma novo = new Firma(naziv, ime, prezime, adresa, email, 000, korisnicko, lozinka, 000); novo.Id = 0; tabelaFirma.InsertAsync(novo); //MessageBox.Show("Usoješno ste se registrovali"); MessageDialog showDialog = new MessageDialog("Uspješno ste se registrovali kao firma"); await showDialog.ShowAsync(); } }
public async Task SaveTaskAsync(AlertItem item) { if (item.Id == null) { await alertTable.InsertAsync(item); } else { await alertTable.UpdateAsync(item); } }
public async Task AddOrUpdateXamagramItemAsync(XamagramItem xamagramItem) { if (string.IsNullOrEmpty(xamagramItem.Id)) { await _xamagramItemTable.InsertAsync(xamagramItem); } else { await _xamagramItemTable.UpdateAsync(xamagramItem); } }
public async Task AddOrUpdateSharitItemAsync(SharitItem sharitItem) { if (string.IsNullOrEmpty(sharitItem.Id)) { await _sharitItemTable.InsertAsync(sharitItem); } else { await _sharitItemTable.UpdateAsync(sharitItem); } }
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 == this.TaskId); if (task != null && task.Id == 0) //Tasks nur hochladen wenn ihre id unbekannt ist, sonst sind sie vermutlich eh schon hochgeladen. await tasksTable.InsertAsync(task); var taskAssignedTo = taskAssignedToRelationship.FirstOrDefault(p => p.TaskId == this.TaskId && p.PersonUserId == user.UserId); if (taskAssignedTo != null && taskAssignedTo.Id == 0) //Tasks nur hochladen wenn ihre id unbekannt ist, sonst sind sie vermutlich eh schon hochgeladen. await taskAssignedToTable.InsertAsync(taskAssignedTo); }
private async void LoadProfile() { LiveConnectClient client = new LiveConnectClient(Connection.Session); LiveOperationResult liveOpResult = await client.GetAsync("me"); //IDictionary<string, object> myResult = liveOpResult.Result; //for (int i = 0; i < myResult.Count; i++) //{ // Debug.WriteLine(myResult.ElementAt(i).Key + " " + myResult.ElementAt(i).Value); //} dynamic dynResult = liveOpResult.Result; // logIn.Text = Connection.UserName; string id = Connection.MobileService.CurrentUser.UserId; string LiveSDKId = dynResult.id; string first_name = dynResult.first_name; string last_name = dynResult.last_name; string link = dynResult.link; string gender = dynResult.gender; string email = dynResult.emails.preferred; liveOpResult = await client.GetAsync("me/picture"); dynamic dynResult2 = liveOpResult.Result; var image = dynResult2.location;// to get the profile photo List<User> usersList = new List<User>(); User = Connection.MobileService.GetTable<User>(); try { usersList = await User.Where(p => p.UserId == id).ToListAsync(); } catch (MobileServiceInvalidOperationException ex) { Debug.WriteLine(ex.Message); } if (usersList.Count == 0) { try { await User.InsertAsync(new User { isAdmin = false, UserId = id, LiveSDKID = LiveSDKId, //UserId = App.MobileService.CurrentUser.UserId, CreatedDate = DateTime.Now, ImageUri = dynResult2.location, FName = first_name, LName = last_name, Email = email, Type = String.Empty }); usersList = await User.Where(p => p.UserId == id).ToListAsync(); Connection.User = usersList.First(); } catch (MobileServiceInvalidOperationException e) { Debug.WriteLine(e.Message); } } else { Connection.User = usersList.First(); } Connection.UserName = dynResult.name; Connection.ImageUri = dynResult2.location; //await Windows.UI.Xaml.DependencyObject.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => // { RegisterDeviceAsync(); AddContacts(); // }); }
private async void RegisterDeviceAsync() { deviceTable = Connection.MobileService.GetTable<Device>(); PushNotificationChannel channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); channel.PushNotificationReceived += channel_PushNotificationReceived; string installationId = InstallationId.GetInstallationIdAsync(); // The server side script device.insert.js will ensure that it creates a new row only when a new User + Device combination is getting added. await deviceTable.InsertAsync( new Device { UserId = Connection.User.UserId, ChannelUri = channel.Uri.ToString(), InstallationId = installationId }); }
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(); } }
private async void phoneNumberChooserTask_Completed(object sender, PhoneNumberResult e) { if (online) { if (e.TaskResult == TaskResult.OK) { MessageBox.Show("Adding " + e.DisplayName + " with phone no. " + e.PhoneNumber + " as friend. Press ok to continue"); var userTable = MobileService.GetTable<Users>(); var list = await userTable.Where(user2 => user2.Phone_no == e.PhoneNumber).ToListAsync(); try { Relations friend = new Relations(); friend.Receiver_Id = user_id; friend.Sender_Id = list[0].Id; friend.Status = 3; relationsTable = MobileService.GetTable<Relations>(); await relationsTable.InsertAsync(friend); } catch { } } } }