Пример #1
0
        //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
            });
        }
Пример #2
0
        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;
                }
            }
        }
Пример #3
0
 // Private Methods
 private Uri CreateDocumentUri(Entities.User user)
 {
     return(UriFactory.CreateDocumentUri(MusicService.DatabaseName, CollectionName, user.Id));
 }
Пример #4
0
        public async Task Delete(Entities.User user)
        {
            DocumentClient client = await _documentClientFactory.GetClient();

            await client.DeleteDocumentAsync(CreateDocumentUri(user));
        }
Пример #5
0
        public async Task Update(Entities.User user)
        {
            DocumentClient client = await _documentClientFactory.GetClient();

            await client.ReplaceDocumentAsync(CreateDocumentUri(user), user);
        }