Skip to content

Instantly share code, notes, and snippets.

@christopherhouse
Created December 13, 2013 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christopherhouse/7949714 to your computer and use it in GitHub Desktop.
Save christopherhouse/7949714 to your computer and use it in GitHub Desktop.
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