//public async Task<List<Artist>> GetByArtistname(string name) //{ // DocumentClient client = await _documentClientFactory.GetClient(); // FeedOptions queryOptions = new FeedOptions { MaxItemCount = -1 }; // IQueryable<Artist> artistQuery = client.CreateDocumentQuery<Artist>( // CreateDocumentCollectionUri(), queryOptions) // .Where(a => a.Name == name); // return artistQuery.ToList(); //} public Artist CreateNew(Entities.User user) { return(new Artist { Id = Guid.NewGuid().ToString(), UserId = user.Id, CreatedDate = DateTime.UtcNow }); }
public async Task AddOrUpdate(Entities.User user) { DocumentClient client = await _documentClientFactory.GetClient(); try { await client.ReadDocumentAsync(CreateDocumentUri(user)); // If we successfully read then call update await Update(user); } catch (DocumentClientException dce) { if (dce.StatusCode == HttpStatusCode.NotFound) { await client.CreateDocumentAsync(CreateDocumentCollectionUri(), user); } else { throw; } } }
// Private Methods private Uri CreateDocumentUri(Entities.User user) { return(UriFactory.CreateDocumentUri(MusicService.DatabaseName, CollectionName, user.Id)); }
public async Task Delete(Entities.User user) { DocumentClient client = await _documentClientFactory.GetClient(); await client.DeleteDocumentAsync(CreateDocumentUri(user)); }
public async Task Update(Entities.User user) { DocumentClient client = await _documentClientFactory.GetClient(); await client.ReplaceDocumentAsync(CreateDocumentUri(user), user); }