private async void MakeNewSpot(string spotName, bool isPrivate, string spotPassword = NULL_PASSWORD) { if (NetworkInterface.GetIsNetworkAvailable()) { // Check whether GPS is on or not if (GeoHelper.GetLocationStatus() != PositionStatus.Disabled) // GPS is on { // Show Pining message and Progress Indicator base.SetProgressRing(uiSpotListProgressRing, true); await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { uiSpotGridView.Visibility = Visibility.Collapsed; uiSpotGridMessage.Text = AppResources.PiningSpot; uiSpotGridMessage.Visibility = Visibility.Visible; }); try { // Wait sign in tastk // Get this Ptc account to make a new spot await TaskHelper.WaitTask(App.AccountManager.GetPtcId()); PtcAccount account = await App.AccountManager.GetPtcAccountAsync(); // Make a new spot around position where the user is. Geoposition geo = await GeoHelper.GetGeopositionAsync(); SpotObject spotObject = new SpotObject(spotName, geo.Coordinate.Point.Position.Latitude, geo.Coordinate.Point.Position.Longitude, account.Email, account.Name, 0, isPrivate, spotPassword, DateTime.Now.ToString()); await App.SpotManager.CreateSpotAsync(spotObject); this.NearSpotViewModel.IsDataLoaded = false; this.Frame.Navigate(typeof(ExplorerPage), new SpotViewItem(spotObject)); } catch { // Show Pining message and Progress Indicator uiSpotGridMessage.Text = AppResources.BadCreateSpotMessage; } // Hide Progress ring. base.SetProgressRing(uiSpotListProgressRing, false); } else // GPS is not on { await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { uiSpotGridMessage.Text = base.GeolocatorStatusMessage(); }); } } else { await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { uiSpotGridMessage.Text = AppResources.InternetUnavailableMessage; }); } }
public async Task <bool> UpdatePtcAccount(PtcAccount account) { MSPtcAccount mspa = PtcAccount.ConvertToMSPtcAccount(account); List <MSStorageAccount> saList = new List <MSStorageAccount>(); await App.MobileService.GetTable <MSPtcAccount>().UpdateAsync(mspa); this.myAccount = account; return(true); }
public async Task <bool> DeletePtcAccount(PtcAccount account) { MSPtcAccount mspa = PtcAccount.ConvertToMSPtcAccount(account); await App.MobileService.GetTable <MSPtcAccount>().DeleteAsync(mspa); App.ApplicationSettings.Remove(PTCACCOUNT_ID); App.ApplicationSettings.Save(); this.myAccount = null; return(true); }
public async Task <bool> CreateNewPtcAccountAsync(PtcAccount account) { MSPtcAccount mspa = PtcAccount.ConvertToMSPtcAccount(account); PtcAccount p = await this.GetPtcAccountAsync(account.Email); if (p != null) { return(false); } await App.MobileService.GetTable <MSPtcAccount>().InsertAsync(mspa); this.SavePtcId(account.Email, account.ProfilePassword); this.myAccount = account; return(true); }
public async Task <bool> SignIn() { if (!this.IsSignIn()) { return(false); } PtcAccount account = await this.GetPtcAccountAsync(); if (account == null) { return(false); } this.myAccount = account; return(true); }
public async Task <PtcAccount> GetPtcAccountAsync() { // TODO : Reset after presentation //TaskCompletionSource<PtcAccount> tcs = new TaskCompletionSource<PtcAccount>(); //if (this.myAccount == null) //{ // if (App.ApplicationSettings.Contains(PTCACCOUNT_ID)) // { // try // { // PtcAccount account = await this.GetPtcAccountAsync((string)App.ApplicationSettings[PTCACCOUNT_ID]); // if (account == null) tcs.SetResult(null); // else tcs.SetResult(account); // } // catch // { // tcs.SetResult(null); // } // } // else // { // tcs.SetResult(null); // } //} //else //{ // tcs.SetResult(this.myAccount); //} //return tcs.Task.Result; TaskCompletionSource <PtcAccount> tcs = new TaskCompletionSource <PtcAccount>(); PtcAccount account = new PtcAccount(); account.Email = App.AccountManager.GetPtcId(); account.AccountType = new StorageAccountType(); account.Name = "User Name"; account.PhoneNumber = "010-3795-8626"; account.UsedSize = 10.0; tcs.SetResult(account); return(tcs.Task.Result); }
public async Task <PtcAccount> GetPtcAccountAsync(string accountId, string password = null) { Expression <Func <MSPtcAccount, bool> > lamda = (a => a.email == accountId); if (password != null) { lamda = (a => a.email == accountId && a.profile_password == password); } MobileServiceCollection <MSPtcAccount, MSPtcAccount> list = await App.MobileService.GetTable <MSPtcAccount>().Where(lamda).ToCollectionAsync(); if (list.Count >= 1) { PtcAccount account = PtcAccount.ConvertToPtcAccount(list.First()); this.myAccount = account; return(account); } else { return(null); } }