private MainViewModel() { // TODO - initialize _eventsTable _eventsTable = Client.GetTable<Event>(); Setup(); }
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(); } }); }
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 override bool FinishedLaunching (UIApplication app, NSDictionary options) { Forms.Init (); // create a new window instance based on the screen size window = new UIWindow (UIScreen.MainScreen.Bounds); #region Azure stuff CurrentPlatform.Init (); Client = new MobileServiceClient ( Constants.Url, Constants.Key); todoTable = Client.GetTable<TodoItem>(); todoItemManager = new TodoItemManager(todoTable); App.SetTodoItemManager (todoItemManager); #endregion region #region Text to Speech stuff App.SetTextToSpeech (new Speech ()); #endregion region // If you have defined a view, add it here: // window.RootViewController = navigationController; window.RootViewController = App.GetMainPage ().CreateViewController (); // make the window visible window.MakeKeyAndVisible (); return true; }
public async Task DoWork() { telemetryTable = client.GetTable<Telemetry>(); var entries = await telemetryTable.Select(e => e.value).ToListAsync(); foreach (var entry in entries) { Console.WriteLine(entry); } var messageTable = client.GetTable<Messages>(); while (true) { Console.WriteLine("Type Message"); var input = Console.ReadLine(); var msg = input; Console.WriteLine("Type R value"); input = Console.ReadLine(); var r = Int32.Parse(input ?? "0"); Console.WriteLine("Type G value"); input = Console.ReadLine(); var g = Int32.Parse(input ?? "0"); Console.WriteLine("Type B value"); input = Console.ReadLine(); var b = Int32.Parse(input ?? "0"); var message = new Messages { R = r, G = g, B = b, Message = msg }; await messageTable.InsertAsync(message); } }
public MainViewModel(IPopupService popupService, SynchronizationContext synchonizationContext) { var client = new MobileServiceClient( _mobileServiceUrl, _mobileServiceKey); _liveAuthClient = new LiveAuthClient(_mobileServiceUrl); // Apply a ServiceFilter to the mobile client to help with our busy indication _mobileServiceClient = client.WithFilter(new DotoServiceFilter( busy => { IsBusy = busy; })); _popupService = popupService; _synchronizationContext = synchonizationContext; _invitesTable = _mobileServiceClient.GetTable<Invite>(); _itemsTable = _mobileServiceClient.GetTable<Item>(); _profilesTable = _mobileServiceClient.GetTable<Profile>(); _listMembersTable = _mobileServiceClient.GetTable<ListMembership>(); _devicesTable = _mobileServiceClient.GetTable<Device>(); _settingsTable = _mobileServiceClient.GetTable<Setting>(); SetupCommands(); LoadSettings(); }
public AzureService() { //comment back in to enable Azure Mobile Services. MobileService = new MobileServiceClient("https://javusdemands.azurewebsites.net/"); expenseTable = MobileService.GetTable<Expense>(); }
public MainScreenMessage(bool isNew, TrainingItem trainingItem, MobileServiceCollection<TrainingItem, TrainingItem> items, IMobileServiceTable<TrainingItem> trainingItemsTable) { _isNewTraining = isNew; _trainingItem = trainingItem; _items = items; _trainingItemsTable = trainingItemsTable; }
public InviteUserViewModel(MainViewModel mainViewModelParent, IMobileServiceTable<Profile> mobileServiceProfileTable) { profileTable = mobileServiceProfileTable; parent = mainViewModelParent; SearchCommand = new DelegateCommand(() => { currentPage = 0; if (String.IsNullOrWhiteSpace(SearchText)) { query = profileTable.Take(profileCountPerPage).IncludeTotalCount(); } else { query = profileTable.Take(profileCountPerPage).IncludeTotalCount().Where (p => p.Name.IndexOf(SearchText) >= 0); } RefreshQueryAsync(); }); NextCommand = new DelegateCommand(() => { currentPage++; RefreshQueryAsync(); }, false); PrevCommand = new DelegateCommand(() => { currentPage--; RefreshQueryAsync(); }, false); }
public InviteUserViewModel(MainViewModel parent, IMobileServiceTable<Profile> profileTable, Action dismiss) { _profileTable = profileTable; _parent = parent; _dismiss = dismiss; SearchCommand = new DelegateCommand(() => { _currentPage = 0; if (String.IsNullOrWhiteSpace(SearchText)) { _query = profileTable.Take(_pageCount).IncludeTotalCount(); } else { _query = profileTable.Take(_pageCount).IncludeTotalCount().Where(p => p.Name.IndexOf(SearchText) > -1); } RefreshQuery(); }); NextCommand = new DelegateCommand(() => { _currentPage++; RefreshQuery(); }, false); PrevCommand = new DelegateCommand(() => { _currentPage--; RefreshQuery(); }, false); }
private ProgressBar progressBar; // Progress spinner to use for table operations // Called when the activity initially gets created protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Activity_To_Do); // Initialize the progress bar progressBar = FindViewById<ProgressBar>(Resource.Id.loadingProgressBar); progressBar.Visibility = ViewStates.Gone; // Create ProgressFilter to handle busy state var progressHandler = new ProgressHandler (); progressHandler.BusyStateChange += (busy) => { if (progressBar != null) progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone; }; try { // PUSH NOTIFICATIONS: Register for push notifications System.Diagnostics.Debug.WriteLine("Registering..."); // Initialize our Gcm Service Hub GcmService.Initialize(this); GcmService.Register(this); // MOBILE SERVICES: Setup azure mobile services - this is separate from push notifications CurrentPlatform.Init (); // Create the Mobile Service Client instance, using the provided // Mobile Service URL and key client = new MobileServiceClient( Constants.ApplicationURL, Constants.ApplicationKey, progressHandler); // Get the Mobile Service Table instance to use todoTable = client.GetTable<TodoItem>(); // USER INTERFACE: setup the Android UI textNewTodo = FindViewById<EditText>(Resource.Id.textNewTodo); // Create an adapter to bind the items with the view adapter = new TodoItemAdapter(this, Resource.Layout.Row_List_To_Do); var listViewTodo = FindViewById<ListView>(Resource.Id.listViewTodo); listViewTodo.Adapter = adapter; // Load the items from the Mobile Service await RefreshItemsFromTableAsync(); } catch (Java.Net.MalformedURLException) { CreateAndShowDialog(new Exception ("There was an error creating the Mobile Service. Verify the URL"), "Error"); } catch (Exception e) { CreateAndShowDialog(e, "Error"); } }
private ProgressBar progressBar; // Progress spinner to use for table operations // Called when the activity initially gets created protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Activity_To_Do); // Initialize the progress bar progressBar = FindViewById<ProgressBar>(Resource.Id.loadingProgressBar); progressBar.Visibility = ViewStates.Gone; // Create ProgressFilter to handle busy state // Create ProgressFilter to handle busy state var progressHandler = new ProgressHandler (); progressHandler.BusyStateChange += (busy) => { if (progressBar != null) progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone; }; try { // Check to ensure everything's setup right PushClient.CheckDevice(this); PushClient.CheckManifest(this); // Register for push notifications System.Diagnostics.Debug.WriteLine("Registering..."); PushClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS); CurrentPlatform.Init (); // Create the Mobile Service Client instance, using the provided // Mobile Service URL and key client = new MobileServiceClient( Constants.ApplicationURL, Constants.ApplicationKey, progressHandler); // Get the Mobile Service Table instance to use todoTable = client.GetTable<TodoItem>(); textNewTodo = FindViewById<EditText>(Resource.Id.textNewTodo); // Create an adapter to bind the items with the view adapter = new TodoItemAdapter(this, Resource.Layout.Row_List_To_Do); var listViewTodo = FindViewById<ListView>(Resource.Id.listViewTodo); listViewTodo.Adapter = adapter; // Load the items from the Mobile Service await RefreshItemsFromTableAsync(); } catch (Java.Net.MalformedURLException) { CreateAndShowDialog(new Exception ("There was an error creating the Mobile Service. Verify the URL"), "Error"); } catch (Exception e) { CreateAndShowDialog(e, "Error"); } }
public ConnectedChatService() { client = new MobileServiceClient(MobileServiceConfig.ApplicationUri, MobileServiceConfig.ApplicationKey); usersTable = client.GetTable<User>(); contentsTable = client.GetTable<PhotoContent>(); recordsTable = client.GetTable<PhotoRecord>(); }
public TodoItemManager () { client = new MobileServiceClient ( Constants.ApplicationURL, Constants.ApplicationKey); todoTable = client.GetTable<TodoItem> (); }
public ToDoItemManager() { _client = new MobileServiceClient( Constants.ApplicationURL, Constants.ApplicationKey); this._todoTable = _client.GetTable<ToDoItem>(); App.SetTodoItemManager(this); }
public MonkeyService () { CurrentPlatform.Init (); client = new MobileServiceClient (Constants.applicationUrl, this); // Create an MSTable instance to allow us to work with the TodoItem table monkeyTable = client.GetTable <MonkeyItem> (); }
public MusicStoreManager() { client = new MobileServiceClient( Constants.ApplicationURL, Constants.GatewayURL, Constants.ApplicationKey); this.todoTable = client.GetTable<TodoItem>(); }
internal async Task InitialLoad() { if (!_initialized) { _usersTable = App.MobileService.GetTable<User>(); _initialized = true; _usersList = await _usersTable.ToListAsync(); } }
internal async Task InitialLoad() { if (!_initialized) { _connectionsTable = App.MobileService.GetTable<Connection>(); _initialized = true; _connectionsList = await _connectionsTable.ToListAsync(); } }
internal async Task InitialLoad() { if (!_initialized) { _messageTable = App.MobileService.GetTable<Message>(); _initialized = true; _messagesList = await _messageTable.ToListAsync(); } }
QSTodoService () { CurrentPlatform.Init (); // Initialize the Mobile Service client with your URL and key client = new MobileServiceClient (applicationURL, applicationKey, this); // Create an MSTable instance to allow us to work with the TodoItem table todoTable = client.GetTable <ToDoItem> (); }
// Constructor protected TodoService() { CurrentPlatform.Init (); Items = new List<TodoItem>(); // TODO:: Uncomment these lines to use Mobile Services client = new MobileServiceClient (Constants.ApplicationURL, Constants.ApplicationKey, this); todoTable = client.GetTable<TodoItem>(); // Create an MSTable instance to allow us to work with the TodoItem table }
public TodoItemManager () { // Establish a link to Azure client = new MobileServiceClient ( Constants.ApplicationURL // Azure no longer requires an Application Key ); // Read any existing todo items from the Azure client todoTable = client.GetTable<TodoItem> (); }
private ProgressBar progressBar; // Progress spinner to use for table operations // Called when the activity initially gets created protected override async void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Activity_To_Do); // Initialize the progress bar progressBar = FindViewById<ProgressBar>(Resource.Id.loadingProgressBar); progressBar.Visibility = ViewStates.Gone; // TODO:: Uncomment the following code when using a mobile service // Create ProgressFilter to handle busy state var progressHandler = new ProgressHandler (); progressHandler.BusyStateChange += (busy) => { if (progressBar != null) progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone; }; try { // TODO:: Uncomment the following code to create the mobile services client CurrentPlatform.Init (); // Create the Mobile Service Client instance, using the provided // Mobile Service URL and key client = new MobileServiceClient( Constants.ApplicationURL, Constants.ApplicationKey, progressHandler); // Get the Mobile Service Table instance to use todoTable = client.GetTable<TodoItem>(); textNewTodo = FindViewById<EditText>(Resource.Id.textNewTodo); // Create an adapter to bind the items with the view adapter = new TodoItemAdapter(this, Resource.Layout.Row_List_To_Do); var listViewTodo = FindViewById<ListView>(Resource.Id.listViewTodo); listViewTodo.Adapter = adapter; // Load the items from the Mobile Service await RefreshItemsFromTableAsync(); } catch (Java.Net.MalformedURLException) { CreateAndShowDialog(new Exception ("There was an error creating the Mobile Service. Verify the URL"), "Error"); } catch (Exception e) { CreateAndShowDialog(e, "Error"); } }
// Constructor protected TodoService() { Items = new List<TodoItem>(); CurrentPlatform.Init (); // Initialize the Mobile Service client with your URL and key client = new MobileServiceClient(Constants.ApplicationURL, Constants.ApplicationKey, this); // Create an MSTable instance to allow us to work with the TodoItem table todoTable = client.GetTable <TodoItem>(); }
// Constructor protected AzureStorageImplementation() { CurrentPlatform.Init (); Items = new List<TodoItem>(); Client = new MobileServiceClient ("https://xamarin-todo.azure-mobile.net/", "", this); //Client = new MobileServiceClient ("https://xamarin-todo.azure-mobile.net/", "555", this); todoTable = Client.GetTable<TodoItem>(); // Create an MSTable instance to allow us to work with the TodoItem table }
QSTodoService () { CurrentPlatform.Init (); // Initialize the Mobile Service client with your URL and key Common.InitializeClient (this); client = Common.MobileService; // Create an MSTable instance to allow us to work with the TodoItem table todoTable = client.GetTable <ToDoItem> (); }
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 AzureClient() { try { _client = new MobileServiceClient("http://mouselight.azurewebsites.net"); _imageQualityTable = _client.GetTable<ImageQualityError>(); } catch (Exception) { } }
public AzureMobileService() { MobileServiceClient = new MobileServiceClient( AppSettings.MobileServiceAddress, AppSettings.MobileServiceApplicationKey ); itemsTable = MobileServiceClient.GetTable<Item>(); if(AppSettings.CreateInitialSchemaForAzureMobileService) CreateInitialSchema(); }
private AzureTableManager() { this.client = new MobileServiceClient("https://captionme.azurewebsites.net"); this.photoCaptionTable = this.client.GetTable <photocaptioninformation>(); }
private IMobileServiceTable <ImageSenseModel> ImageSenseTable; //check this private AzureManager() { this.client = new MobileServiceClient("http://imagesense.azurewebsites.net"); this.ImageSenseTable = this.client.GetTable <ImageSenseModel>(); }
async void MyItemsSource_CollectionChangedAsync(object sender, NotifyCollectionChangedEventArgs e) { var x = sender as TrulyObservableCollection <Status>; if (x != null && this.ListShowDb.Count == x.Count) { // i is the index foreach (var item in x.Select((value, i) => new { i, value })) { // Checking is selection has been made for this products if (item.value.Selected != this.ListShowDb[item.i]) { // This excuted when selection of a buyer has been made Console.WriteLine($"Assigned { item.value.Selected} to buy { item.value.Name}"); // Updating the element in the list this.ListShowDb[item.i] = item.value.Selected; IMobileServiceTable <Status> _status = App.MobileService.GetTable <Status>(); MobileServiceCollection <Status, Status> _statusenum = await _status .Where(u => u.Name != string.Empty) .ToCollectionAsync(); if (_statusenum.Any(p => p.Name == item.value.Name)) { // Updating the db with the buyer name selected information var modified = _statusenum.SingleOrDefault(p => p.Name == item.value.Name); var cc = await _status.LookupAsync(modified.Id); await _status.DeleteAsync(cc); cc.Selected = item.value.Selected; await _status.InsertAsync(cc); } else { // Adding information into db with the buyer name selected await App.MobileService.GetTable <Status>().InsertAsync(new Status() { Name = item.value.Name, Selected = item.value.Selected, CreatedAt = null }); } } else { // this is executed when shopping was done IMobileServiceTable <Status> _status = App.MobileService.GetTable <Status>(); MobileServiceCollection <Status, Status> _statusenum = await _status .Where(u => u.Name != string.Empty) .ToCollectionAsync(); var excuted = _statusenum.SingleOrDefault(g => g.Name == item.value.Name); if (excuted != null && item.value.Executed != excuted.Executed) { // Changing information about execution Console.WriteLine($" {item.value.Name} was bought = {item.value.Executed}"); var modified = _statusenum.SingleOrDefault(g => g.Name == item.value.Name); await App.MobileService.GetTable <Status>().DeleteAsync(modified); modified.Executed = item.value.Executed; await App.MobileService.GetTable <Status>().InsertAsync(modified); } } } } if (x.Count != this.ListShowDb.Count) { this.ListShowDb.Clear(); foreach (var item in x) { this.ListShowDb.Add(item.Selected); } } }
public HistoryManager() { table = MainActivity.mClient.GetTable <History>(); }
private AzureManager() { this.client = new MobileServiceClient("http://moodtimeline13.azurewebsites.net"); this.timelineTable = this.client.GetTable <Timeline>(); }
public UsersManager() { client = new MobileServiceClient(Constants.ApplicationURL); usersTable = client.GetTable <User>(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(SmartBasket.Resource.Layout.Login); // Create the client instance, using the mobile app backend URL. client = new MobileServiceClient(applicationURL); #if OFFLINE_SYNC_ENABLED await InitLocalStoreAsync(); // Get the sync table instance to use to store TodoItem rows. todoTable = client.GetSyncTable <ToDoItem>(); #else userTable = client.GetTable <User>(); #endif CurrentPlatform.Init(); EditText input = this.FindViewById <EditText>(SmartBasket.Resource.Id.input_id); EditText pass = this.FindViewById <EditText>(SmartBasket.Resource.Id.input_password); Button sendButton = this.FindViewById <Button>(SmartBasket.Resource.Id.btn_login); var m_activity = new Intent(this, typeof(ToDoActivity)); sendButton.Click += async delegate { var list = await userTable.Where(user => user.userId == (input.Text)).ToListAsync(); int i = 0; foreach (User current in list) { if (current.password.Equals(pass.Text)) { Toast.MakeText(this, "Login Succeeded", ToastLength.Short).Show(); m_activity = new Intent(this, typeof(ToDoActivity)); this.StartActivity(m_activity); } else { Toast.MakeText(this, "Login Failed", ToastLength.Short).Show(); } i++; } if (i == 0) { Toast.MakeText(this, "Login Failed", ToastLength.Short).Show(); } // Toast.MakeText(this, input.Text.ToString(), ToastLength.Short).Show(); /* * var usr1 = new User(); * usr1.userId = "1234"; * usr1.password = "******"; */ try { // Insert the new item into the local store. //await userTable.InsertAsync(usr1); } catch (Exception e) { //CreateAndShowDialog(e, "Error"); } }; }
public AndroidAzureEasyTableClient() { client = new HttpClient(); mobileServiceCLient = new MobileServiceClient(@"http://mobiletranslator.azurewebsites.net"); translatedTextTable = mobileServiceCLient.GetTable("TranslatedText"); }
public AzureCustomerDataStore() { this._customersTable = App.MobileService.GetTable <Customer>(); }
private AzureManager() { this.client = new MobileServiceClient("https://alexfabrikamfood.azurewebsites.net"); this.foodTable = this.client.GetTable <Food>(); }
private AzureManager() { this.client = new MobileServiceClient("http://shoe.azurewebsites.net"); this.shoedb = this.client.GetTable <ShoeModel>(); }
public SyncManager() { MobileService = new MobileServiceClient("https://waterheatertracker.azurewebsites.net"); heaterTable = MobileService.GetTable <WaterHeater>(); }
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); }
public async Task SendEvidence(LabItem userEvidence) { Client = new MobileServiceClient(@"http://xamarin-diplomado.azurewebsites.net/"); LabItemTable = Client.GetTable <LabItem>(); await LabItemTable.InsertAsync(userEvidence); }
public CharacterService() { //Client = new MobileServiceClient(Constants.MobileServiceClientUrl); CharacterTable = XamarinAllianceApp.App.MobileService.GetTable <Character>(); }
private AzureManager() { this.client = new MobileServiceClient("http://studyblocks.azurewebsites.net"); this.studyblockTable = this.client.GetTable <StudyBlock>(); }
public AzureCloudTable(MobileServiceClient client) { this.table = client.GetTable <T>(); }
private async Task AsyncTableOperationsWithValidStringIdAgainstStringIdTable() { await EnsureEmptyTableAsync <ToDoWithStringId>(); string[] testIdData = IdTestData.ValidStringIds; IMobileServiceTable <ToDoWithStringId> table = GetClient().GetTable <ToDoWithStringId>(); foreach (string testId in testIdData) { ToDoWithStringId item = new ToDoWithStringId() { Id = testId, Name = "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].Name); // 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].Name); // Projection var projectedResults = await table.Select(i => new { XId = i.Id, XString = i.Name }).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.Name); // Update item.Name = "What?"; await table.UpdateAsync(item); Assert.AreEqual(testId, item.Id); Assert.AreEqual("What?", item.Name); // Refresh item = new ToDoWithStringId() { Id = testId, Name = "Hey" }; await table.RefreshAsync(item); Assert.AreEqual(testId, item.Id); Assert.AreEqual("What?", item.Name); // 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].Name); await table.DeleteAsync(item); } }
public AzureServiceBase() { _client = new MobileServiceClient(serviceUrl); _table = _client.GetTable <TEntity>(); }
public async Task AsyncFilterSelectOrderingOperationsNotImpactedBySystemProperties() { await EnsureEmptyTableAsync <RoundTripTableItemWithSystemPropertiesType>(); IMobileServiceTable <RoundTripTableItemWithSystemPropertiesType> table = GetClient().GetTable <RoundTripTableItemWithSystemPropertiesType>(); List <RoundTripTableItemWithSystemPropertiesType> items = new List <RoundTripTableItemWithSystemPropertiesType>(); // Insert some items for (int id = 0; id < 5; id++) { RoundTripTableItemWithSystemPropertiesType item = new RoundTripTableItemWithSystemPropertiesType() { Id = id.ToString(), Name = "a value" }; await table.InsertAsync(item); Assert.IsNotNull(item.CreatedAt); Assert.IsNotNull(item.UpdatedAt); Assert.IsNotNull(item.Version); items.Add(item); } // Ordering var results = await table.OrderBy(t => t.CreatedAt).ToEnumerableAsync(); // Fails here with .NET runtime. Why?? RoundTripTableItemWithSystemPropertiesType[] orderItems = results.ToArray(); for (int i = 0; i < orderItems.Length - 1; i++) { Assert.IsTrue(int.Parse(orderItems[i].Id) < int.Parse(orderItems[i + 1].Id)); } results = await table.OrderBy(t => t.UpdatedAt).ToEnumerableAsync(); orderItems = results.ToArray(); for (int i = 0; i < orderItems.Length - 1; i++) { Assert.IsTrue(int.Parse(orderItems[i].Id) < int.Parse(orderItems[i + 1].Id)); } results = await table.OrderBy(t => t.Version).ToEnumerableAsync(); orderItems = results.ToArray(); for (int i = 0; i < orderItems.Length - 1; i++) { Assert.IsTrue(int.Parse(orderItems[i].Id) < int.Parse(orderItems[i + 1].Id)); } // Filtering results = await table.Where(t => t.CreatedAt >= items[4].CreatedAt).ToEnumerableAsync(); RoundTripTableItemWithSystemPropertiesType[] filteredItems = results.ToArray(); for (int i = 0; i < filteredItems.Length - 1; i++) { Assert.IsTrue(filteredItems[i].CreatedAt >= items[4].CreatedAt); } results = await table.Where(t => t.UpdatedAt >= items[4].UpdatedAt).ToEnumerableAsync(); filteredItems = results.ToArray(); for (int i = 0; i < filteredItems.Length - 1; i++) { Assert.IsTrue(filteredItems[i].UpdatedAt >= items[4].UpdatedAt); } // TODO: Seperate to own test, to not run for .NET / Fix.Net /* * results = await table.Where(t => t.Version == items[4].Version).ToEnumerableAsync(); * filteredItems = results.ToArray(); * * for (int i = 0; i < filteredItems.Length - 1; i++) * { * Assert.IsTrue(filteredItems[i].Version == items[4].Version); * } */ // Selection var selectionResults = await table.Select(t => new { Id = t.Id, CreatedAt = t.CreatedAt }).ToEnumerableAsync(); var selectedItems = selectionResults.ToArray(); for (int i = 0; i < selectedItems.Length; i++) { var item = items.Where(t => t.Id == selectedItems[i].Id).FirstOrDefault(); Assert.IsTrue(item.CreatedAt == selectedItems[i].CreatedAt); } var selectionResults2 = await table.Select(t => new { Id = t.Id, UpdatedAt = t.UpdatedAt }).ToEnumerableAsync(); var selectedItems2 = selectionResults2.ToArray(); for (int i = 0; i < selectedItems2.Length; i++) { var item = items.Where(t => t.Id == selectedItems2[i].Id).FirstOrDefault(); Assert.IsTrue(item.UpdatedAt == selectedItems2[i].UpdatedAt); } var selectionResults3 = await table.Select(t => new { Id = t.Id, Version = t.Version }).ToEnumerableAsync(); var selectedItems3 = selectionResults3.ToArray(); for (int i = 0; i < selectedItems3.Length; i++) { var item = items.Where(t => t.Id == selectedItems3[i].Id).FirstOrDefault(); Assert.IsTrue(item.Version == selectedItems3[i].Version); } // Delete foreach (var item in items) { await table.DeleteAsync(item); } }
private AzureManager() { this.client = new MobileServiceClient("http://ctsbb.azurewebsites.net"); this.Branch_Tables = this.client.GetTable <Branch_Tables>(); this.Staff_Table = this.client.GetTable <Staff>(); }
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); }
async void UpdateLists() { IMobileServiceTable <Item> _products = App.MobileService.GetTable <Item>(); MobileServiceCollection <Item, Item> _productsenum = await _products .Where(i => i.Name != string.Empty) .ToCollectionAsync(); foreach (var item in _productsenum) { // Adding products to the list from the db if (!this.List.Any(x => x.Name == item.Name)) { this.List.Add(item); } } // Gettings number of products this.NumberofItems.Value = this.List.Count(); IMobileServiceTable <User> _users = App.MobileService.GetTable <User>(); MobileServiceCollection <User, User> _usersenum = await _users .Where(u => u.FirstName != string.Empty) .ToCollectionAsync(); foreach (var user in _usersenum) { if (!this.UserList.Any(x => x.Id == user.Id)) { // Adding users to the list from the db this.UserList.Add(user); } } // Gettings number of buyers this.NumberofUsers.Value = this.UserList.Count(); foreach (var item in this.List) { var Li = new ObservableCollection <User>(); foreach (var us in this.UserList) { // Gettings Buyers list from the db Li.Add(us); } if (!this.ListShow.Any(x => x.Name == item.Name)) { IMobileServiceTable <Status> _status = App.MobileService.GetTable <Status>(); MobileServiceCollection <Status, Status> _statusenum = await _status .Where(u => u.Name != string.Empty) .ToCollectionAsync(); if (_statusenum.Any(p => p.Name == item.Name)) { // Get selection from the db and show var selecteduser = _statusenum.SingleOrDefault(p => p.Name == item.Name).Selected; this.ListShow.Add(new Status(new ReactiveProperty <User>(this.UserList.SingleOrDefault(g => g.FirstName == selecteduser)), new ReactiveProperty <bool>(_statusenum.SingleOrDefault(p => p.Name == item.Name).Executed)) { Name = item.Name, UserList = Li }); } else { // Get selection from the db and show this.ListShow.Add(new Status { Name = item.Name, UserList = Li }); } } } }
public async Task AsyncTableOperationsWithIntegerAsStringIdAgainstIntIdTable() { await EnsureEmptyTableAsync <ToDoWithStringIdAgainstIntIdTable>(); IMobileServiceTable <ToDoWithStringIdAgainstIntIdTable> stringIdTable = GetClient().GetTable <ToDoWithStringIdAgainstIntIdTable>(); ToDoWithStringIdAgainstIntIdTable item = new ToDoWithStringIdAgainstIntIdTable() { Name = "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].Name); // 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].Name); // Projection var projectedResults = await stringIdTable.Select(i => new { XId = i.Id, XString = i.Name }).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.Name); // Update stringIdItem.Name = "What?"; await stringIdTable.UpdateAsync(stringIdItem); Assert.AreEqual(testId, stringIdItem.Id); Assert.AreEqual("What?", stringIdItem.Name); // Refresh stringIdItem = new ToDoWithStringIdAgainstIntIdTable() { Id = testId, Name = "Hey" }; await stringIdTable.RefreshAsync(stringIdItem); Assert.AreEqual(testId, stringIdItem.Id); Assert.AreEqual("What?", stringIdItem.Name); // 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].Name); // Delete await stringIdTable.DeleteAsync(item); }
public async Task RefreshItems() { if (friendsListLoaded) { Debug.WriteLine("Attemting to refresh items."); itemsByFriends.Clear(); friendShareStatus.Clear(); List <SharedItem> allItems; List <SharedItem> itemsByFriend; sharedItemsTable = MobileServiceClient.GetTable <SharedItem>(); //await sharedItemsTable.InsertAsync(new SharedItem { facebookUserID = "1234", name = "Deneme", date = DateTime.Now, description = "deneme", url = "www.deneme.com" }); allItems = await sharedItemsTable.ToListAsync(); foreach (SharedItem item in allItems) { Debug.WriteLine("UID: " + item.facebookUserID); } //IMobileServiceTableQuery<SharedItem> query = sharedItemsTable.Where(x => x.facebookUserID == FacebookId); //foreach (Friend friend in friends) { // query = query.Where(x => x.facebookUserID == friend.facebookUserID); //} //List<SharedItem> allItems = await query.ToListAsync(); //string[] fbIDs = new string[friends.Count + 1]; //fbIDs[0] = FacebookId; //for (int i = 0; i < friends.Count; i++) { // fbIDs[i + 1] = friends[i].facebookUserID; //} //allItems = await sharedItemsTable.Where(x => fbIDs.Contains<string>(x.facebookUserID)).ToListAsync(); // My items itemsByFriend = allItems.Where <SharedItem>(x => x.facebookUserID.Equals(FacebookId)).ToList <SharedItem>(); itemsByFriends.Add(FacebookId, itemsByFriend); friendShareStatus.Add(FacebookId, itemsByFriend.Count != 0); // My items // Friends' items foreach (Friend friend in friends) { itemsByFriend = allItems.Where <SharedItem>(x => x.facebookUserID.Equals(friend.facebookUserID)).ToList <SharedItem>(); itemsByFriends.Add(friend.facebookUserID, itemsByFriend); friendShareStatus.Add(friend.facebookUserID, itemsByFriend.Count != 0); } // Friends' items allItems = null; Debug.WriteLine("Refreshed items."); ShowAllFriends(); itemsLoaded = true; } else { Debug.WriteLine("Can't refresh items, friend list is not yet loaded!"); } }
public async Task AsyncTableOperationsWithStringIdAgainstIntegerIdTable() { Log("This test fails with the .NET backend since in .NET the DTO always has string-id. In Node, querying an int-id column for a string causes an error."); 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() { Name = 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, Name = "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, Name = "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, Name = "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, Name = "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); } }
private AzureManager() { this.client = new MobileServiceClient("http://notcbd.azurewebsites.net"); this.table = this.client.GetTable <easytable>(); }
public BaseStoreFixture <T> WithTable(IMobileServiceTable <T> table) => this.With(ref _serviceTable, table);
public FriendManager() { client = new MobileServiceClient(Constants.ApplicationURL); friendTable = client.GetTable <Friend>(); }
private CartManager() { this.client = new MobileServiceClient("https://nandoso2016bot.azurewebsites.net"); this.cartTable = this.client.GetTable <Cart>(); }