Răsfoiți Sursa

Started implementing App Service Helpers

Mike James 9 ani în urmă
părinte
comite
2139ecd4e2

+ 6 - 0
HandsOnLab/Finish/DevDaysSpeakers/DevDaysSpeakers.iOS/DevDaysSpeakers.iOS.csproj

@@ -177,6 +177,12 @@
       <Private>True</Private>
     </Reference>
     <Reference Include="Xamarin.iOS" />
+    <Reference Include="Plugin.Connectivity">
+      <HintPath>..\..\packages\Xam.Plugin.Connectivity.2.2.2\lib\Xamarin.iOS10\Plugin.Connectivity.dll</HintPath>
+    </Reference>
+    <Reference Include="Plugin.Connectivity.Abstractions">
+      <HintPath>..\..\packages\Xam.Plugin.Connectivity.2.2.2\lib\Xamarin.iOS10\Plugin.Connectivity.Abstractions.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\DevDaysSpeakers\DevDaysSpeakers.csproj">

+ 1 - 0
HandsOnLab/Finish/DevDaysSpeakers/DevDaysSpeakers.iOS/packages.config

@@ -7,6 +7,7 @@
   <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="xamarinios10" />
   <package id="Newtonsoft.Json" version="6.0.4" targetFramework="xamarinios10" />
   <package id="SQLitePCL" version="3.8.7.2" targetFramework="xamarinios10" />
+  <package id="Xam.Plugin.Connectivity" version="2.2.2" targetFramework="xamarinios10" />
   <package id="Xam.Plugins.TextToSpeech" version="2.0.0" targetFramework="xamarinios10" />
   <package id="Xamarin.Forms" version="2.3.0.107" targetFramework="xamarinios10" />
 </packages>

+ 8 - 0
HandsOnLab/Finish/DevDaysSpeakers/DevDaysSpeakers/App.cs

@@ -1,4 +1,5 @@
 using DevDaysSpeakers.View;
+using AppServiceHelpers;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -12,12 +13,19 @@ namespace DevDaysSpeakers
     {
         public App()
         {
+            var client = EasyMobileServiceClient.Create();
+            client.Initialize("https://montemagnospeakers.azurewebsites.net");
+            client.RegisterTable<Model.Speaker>();
+            client.FinalizeSchema();
+
             // The root page of your application
             var content = new SpeakersPage();
 
             MainPage = new NavigationPage(content);
         }
 
+
+
         protected override void OnStart()
         {
             // Handle when your app starts

+ 9 - 0
HandsOnLab/Finish/DevDaysSpeakers/DevDaysSpeakers/DevDaysSpeakers.csproj

@@ -96,6 +96,15 @@
       <HintPath>..\..\packages\Xamarin.Forms.2.3.0.107\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Xaml.dll</HintPath>
       <Private>True</Private>
     </Reference>
+    <Reference Include="Plugin.Connectivity">
+      <HintPath>..\..\packages\Xam.Plugin.Connectivity.2.2.2\lib\portable-net45+wp80+wp81+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+Xamarin.Mac20+UAP10\Plugin.Connectivity.dll</HintPath>
+    </Reference>
+    <Reference Include="Plugin.Connectivity.Abstractions">
+      <HintPath>..\..\packages\Xam.Plugin.Connectivity.2.2.2\lib\portable-net45+wp80+wp81+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+Xamarin.Mac20+UAP10\Plugin.Connectivity.Abstractions.dll</HintPath>
+    </Reference>
+    <Reference Include="Azure.Mobile">
+      <HintPath>..\..\packages\AppService.Helpers.1.0.1\lib\Azure.Mobile.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <None Include="app.config" />

+ 1 - 2
HandsOnLab/Finish/DevDaysSpeakers/DevDaysSpeakers/Model/Speaker.cs

@@ -6,9 +6,8 @@ using System.Threading.Tasks;
 
 namespace DevDaysSpeakers.Model
 {
-    public class Speaker
+    public class Speaker : AppServiceHelpers.Models.EntityData
     {
-        public string Id { get; set; }
         public string Name { get; set; }
         public string Description { get; set; }
         public string Website { get; set; }

+ 8 - 2
HandsOnLab/Finish/DevDaysSpeakers/DevDaysSpeakers/ViewModel/SpeakersViewModel.cs

@@ -10,12 +10,13 @@ using DevDaysSpeakers.Model;
 using System.Net.Http;
 using Newtonsoft.Json;
 using System.Collections.ObjectModel;
+using AppServiceHelpers.Abstractions;
 
 namespace DevDaysSpeakers.ViewModel
 {
     public class SpeakersViewModel : INotifyPropertyChanged
     {
-
+        public ITableDataStore<Speaker> Table { get; set;}
         public ObservableCollection<Speaker> Speakers { get; set; }
         public SpeakersViewModel()
         {
@@ -43,8 +44,13 @@ namespace DevDaysSpeakers.ViewModel
             {
                 IsBusy = true;
 
+                if (Table == null)
+                {
+                    var client = new AppServiceHelpers.EasyMobileServiceClient();
+                    Table = client.Table<Speaker>();
+                }
 
-                var items = await AzureStore.Current.GetSpeakers();
+                var items = await Table.GetItemsAsync();
 
                 Speakers.Clear();
                 foreach (var item in items)

+ 2 - 0
HandsOnLab/Finish/DevDaysSpeakers/DevDaysSpeakers/packages.config

@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
+  <package id="AppService.Helpers" version="1.0.1" targetFramework="portable-net45+win+wpa81+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarintvos10+xamarinwatchos10+xamarinios10" />
   <package id="Microsoft.Azure.Mobile.Client" version="2.1.0" targetFramework="portable45-net45+win8+wp8+wpa81" />
   <package id="Microsoft.Azure.Mobile.Client.SQLiteStore" version="2.1.0" targetFramework="portable45-net45+win8+wp8+wpa81" />
   <package id="Microsoft.Bcl" version="1.1.10" targetFramework="portable45-net45+win8+wp8+wpa81" />
@@ -7,6 +8,7 @@
   <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="portable45-net45+win8+wp8+wpa81" />
   <package id="Newtonsoft.Json" version="6.0.4" targetFramework="portable45-net45+win8+wp8+wpa81" />
   <package id="SQLitePCL" version="3.8.7.2" targetFramework="portable45-net45+win8+wp8+wpa81" />
+  <package id="Xam.Plugin.Connectivity" version="2.2.2" targetFramework="portable-net45+win+wpa81+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarintvos10+xamarinwatchos10+xamarinios10" />
   <package id="Xam.Plugins.TextToSpeech" version="2.0.0" targetFramework="portable45-net45+win8+wp8+wpa81" />
   <package id="Xamarin.Forms" version="2.3.0.107" targetFramework="portable45-net45+win8+wp8+wpa81" />
 </packages>