Created
December 13, 2013 19:22
-
-
Save christopherhouse/7949714 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading.Tasks; | |
using Microsoft.WindowsAzure.MobileServices; | |
using ThirteenDaysAWeek.AzureCustomAuth.Handlers; | |
using ThirteenDaysAWeek.AzureCustomAuth.Factories; | |
using ThirteenDaysAWeek.AzureCustomAuth.Models; | |
namespace ThirteenDaysAWeek.AzureCustomAuth.Services | |
{ | |
public class TestDataService | |
{ | |
public async Task AddTestData() | |
{ | |
using (var handler = new ZumoAuthHeaderHandler()) | |
{ | |
using (var client = MobileServiceClientFactory.CreateClient(handler)) | |
{ | |
var data = new TestData { | |
DateCreated = DateTime.Now | |
}; | |
var table = client.GetTable<TestData>(); | |
await table.InsertAsync(data); | |
} | |
} | |
} | |
public async Task<TestData> GetMostRecentItem() | |
{ | |
using (var handler = new ZumoAuthHeaderHandler()) | |
{ | |
using (var client = MobileServiceClientFactory.CreateClient(handler)) | |
{ | |
var table = client.GetTable<TestData>(); | |
var query = table.Take(1) | |
.OrderByDescending(d => d.DateCreated); | |
var data = await query.ToListAsync(); | |
return data.First(); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment