Beispiel #1
0
 public async static Task GoOnVacation(DocumentClient client, DocumentCollection collection, string jeffersons, bool left)
 {
     var family = GetFamily(client, collection, jeffersons);
     dynamic doc = GetDocumentById(client, collection,family.id);
     Family f = doc;
     f.IsHome = false;
     var task = await client.ReplaceDocumentAsync(doc.SelfLink, f);
     
 }
        public async Task <DocumentDBResultDto> UpdateDocumentAsync(CosmosDBDocument document)
        {
            var result = await _cosmosDBClient.ReplaceDocumentAsync(UriFactory.CreateDocumentUri(_dbSetting.DatabaseId, _dbSetting.CollectionId, document.Id), document, CreateRequestOptions("*"));

            return(new DocumentDBResultDto()
            {
                Id = result.Resource.Id,
                ETag = result.Resource.ETag
            });
        }
Beispiel #3
0
        private static async Task UpdateCourse(Guid guid, DocumentCollection documentCollection)
        {
            DocumentClient documentClient = new DocumentClient(new Uri("https://schooltest.documents.azure.com:443/"),
                "Of414DnEibhmqeSTB0pKShdQtR6dxxfXP8uT93pggxoumKthJGzuECCUJZ27Pqf846VUkFfOrraMTQ74PZaywA==");

            Course course = documentClient.CreateDocumentQuery<Course>(documentCollection.DocumentsLink, 
                new SqlQuerySpec(string.Format("SELECT * FROM c WHERE c.CourseId = '{0}'", guid))).AsEnumerable().FirstOrDefault();

            if (course == null)
                return;

            course.Name = "THIS IS THE PERFECT NAME...2..";

            await documentClient.ReplaceDocumentAsync(course);
        }
        public void Start()
        {
            QueueUtility.Listen<EventController.Position>("PositionQueue", async position =>
            {
                var client = new DocumentClient(new Uri("https://etamanager.documents.azure.com:443/"), "HIgfJLkqRsemDoAv62MSn0/UFK2dC9RxtAopuV3rAa7f1tCqou/A2xbh1ShLDkKDaWOPLEsZ0sl7dGzjrEz36A==");
                var trip = client.CreateDocumentQuery<TripDocument>("dbs/-gIgAA==/colls/-gIgALa0OwA=").Where(t => t.Code == position.TripCode).AsEnumerable().FirstOrDefault();
                if (trip != null)
                {
                    trip.ExpectedArrival = position.DT;
                    await client.ReplaceDocumentAsync(trip.SelfLink, trip);
                }

                var update = new EventController.ETAUpdate { code = position.TripCode, expectedArrival = position.DT };
                QueueUtility.Send("ETAUpdateQueue", update);
            });
            QueueUtility.Listen<EventController.ETAUpdate>("ETAUpdateQueue", update => this.tripsHub.Clients.All.addNewMessageToPage(update));
        }
Beispiel #5
0
        /// <summary>
        /// Internal Member to Update Request and Status properties Azure DocumentDB by url 
        /// </summary>
        /// <param name="client"></param>
        /// <param name="selfLink"></param>
        /// <param name="request"></param>
        /// <param name="status"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        private Document UpdateSiteRequestStatusByUrl(DocumentClient client, string selfLink, SiteInformation request, SiteRequestStatus status, string message)
        {
            dynamic _requestDocument = client.CreateDocumentQuery<Document>(selfLink).Where(d => d.Id == request.Id).AsEnumerable().FirstOrDefault();
            Document _d = _requestDocument; //Cast to Document to get the Selflink property
            Document _dReturnResult = null;
            SiteInformation _requestToUpdate = _requestDocument;
            if(!string.IsNullOrEmpty(message))
            {
                _requestToUpdate.RequestStatusMessage = message;
            }
            _requestToUpdate.EnumStatus = status;
            var savedRequestTask = Task.FromResult(client.ReplaceDocumentAsync(_d.SelfLink, _requestToUpdate));

            if (!savedRequestTask.Result.IsFaulted)
            {
                _dReturnResult = savedRequestTask.Result.Result;
            }
            return _dReturnResult;
        }
        private static async Task ResetActiveTransactionsDocIfNotExists()
        {
            var client = new DocumentClient(new Uri(Endpoint), AuthKey);
            Uri collectionLink = UriFactory.CreateDocumentUri(DbName, CollectionName, activeTransactionsDocId.ToString());

            ActiveTransactions activeTransactionsDoc = new ActiveTransactions
            {
                Id = activeTransactionsDocId,
                Transactions = new List<string>()
            };

            try {
                await client.ReplaceDocumentAsync(collectionLink, activeTransactionsDoc);
            }
            catch (DocumentClientException de)
            {
                throw;
            }
        }