public class CourseStore
{
DocumentClient _client;
Uri _coursesLink;
public CourseStore()
{
var uri = new Uri("https://nosql-test.documents.azure.com:443/");
_client = new DocumentClient(uri, "y0haYAcM8DaOEeTm53leyoueQj4P1qYd9Q3aKnKhxq5aQmRAg88bLcqSP6yORZJvESH6qazeMmN3xRWgHjPWBA==");
_coursesLink = UriFactory.CreateDocumentCollectionUri("nosql-test", "courses");
}
public async Task InsertCourses(IEnumerable<Course> data)
{
foreach (var course in data)
{
await _client.CreateDocumentAsync(_coursesLink, course);
}
}
public IEnumerable<Course> GetAllCourses()
{
return _client.CreateDocumentQuery<Course>(_coursesLink).OrderBy(c=>c.Title);
}
}