Exemple #1
0
        public EvaluationResult <IProductMention> CosmosDBTableDownload(ICosmosDBTableContext context, string tableName)
        {
            var result = new EvaluationResult <IProductMention>();

            try
            {
                result.Results = new List <IProductMention>(context.GetMentions(tableName));
                result.Code    = result.Results.Count > 0 ? 0 : 1;
                result.Text    = result.Code == 0 ? "Successfully downloaded table data from Cosmos DB account" :
                                 "There were no errors, but no records were returned from Cosmos DB table.";
            }
            catch (Exception ex)
            {
                result.Code = 2;
                result.Text = $"There was an error retrieving tabular data from Cosmos DB: {ex.Message}";
            }

            return(result);
        }
Exemple #2
0
        public EvaluationResult <IProductMention> CosmosDBTableUpload(ICosmosDBTableContext context, string tableName)
        {
            var result = new EvaluationResult <IProductMention>();

            try
            {
                var data = sampleData.ProductMentionData();
                context.CreateTable(tableName);
                context.LoadMentions(data, tableName);
                result.Code = 0;
                result.Text = "Successfully uploaded table data to Cosmos DB account.";
            }
            catch (Exception ex)
            {
                result.Code = 2;
                result.Text = $"There was an error uploading table data: {ex.Message}";
            }


            return(result);
        }