Ejemplo n.º 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
            });
        }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 3
0
 // Private Methods
 private Uri CreateDocumentUri(Entities.User user)
 {
     return(UriFactory.CreateDocumentUri(MusicService.DatabaseName, CollectionName, user.Id));
 }
Ejemplo n.º 4
0
        public async Task Delete(Entities.User user)
        {
            DocumentClient client = await _documentClientFactory.GetClient();

            await client.DeleteDocumentAsync(CreateDocumentUri(user));
        }
Ejemplo n.º 5
0
        public async Task Update(Entities.User user)
        {
            DocumentClient client = await _documentClientFactory.GetClient();

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