Exemple #1
0
        public async Task <DomainUserSettings> UpdateAsync(DomainUserSettings settings)
        {
            try
            {
                var documentUri = GetDocumentUri(settings.Id.ToString());

                var storeEntity = Mapper.Map <DomainUserSettings, UserSettings>(settings);
                storeEntity.Updated = DateTimeOffset.UtcNow;

                await Client.ReplaceDocumentAsync(documentUri, storeEntity);

                return(Mapper.Map <UserSettings, DomainUserSettings>(storeEntity));
            }
            catch (DocumentClientException e)
            {
                throw GetException(e);
            }
        }
Exemple #2
0
        public async Task <DomainUserSettings> SaveAsync(DomainUserSettings settings)
        {
            try
            {
                var collectionUri = GetCollectionUri();

                var storeEntity = new UserSettings();
                storeEntity = Mapper.Map(settings, storeEntity);

                storeEntity.Created = DateTimeOffset.UtcNow;
                storeEntity.Updated = storeEntity.Created;
                storeEntity.Id      = Guid.NewGuid();
                await Client.CreateDocumentAsync(collectionUri, storeEntity);

                return(Mapper.Map <UserSettings, DomainUserSettings>(storeEntity));
            }
            catch (DocumentClientException e)
            {
                throw GetException(e);
            }
        }