Ejemplo n.º 1
0
        public async Task <ActionResult> GetGridData(UpdateRequestData UserModel)
        {
            var azureconfiguration = ConfigInit.getConfiguration();

            var            cosmosDBResponse       = new CosmosAPIService();
            DocumentClient documentClient         = new DocumentClient(new Uri(azureconfiguration.AzureCosmosDBConnectionString), azureconfiguration.AzureCosmonDBPrimaryKey1);
            var            createDataBaseResponse = await documentClient.CreateDatabaseIfNotExistsAsync(new Microsoft.Azure.Documents.Database {
                Id = "CognitiveAPIDemoDataSource"
            });

            var createDataBaseCollectionResponse = await documentClient.CreateDocumentCollectionIfNotExistsAsync(UriFactory.CreateDatabaseUri("CognitiveAPIDemoDataSource"), new DocumentCollection { Id = "PocCollection" }, new RequestOptions { OfferThroughput = 1000 });

            var documentResponse = await cosmosDBResponse.UpdateDocumentCollection(UserModel, documentClient);

            if (!documentResponse)
            {
                return(Json(new { cosmosID = UserModel.cosmosID, imageText = UserModel.imageText, status = "Fail" }));
            }

            return(Json(new { cosmosID = UserModel.cosmosID, imageText = UserModel.imageText, status = "Success" }));
        }