Exemple #1
0
        protected async Task <List <T> > Get()
        {
            using (var bucket = DbCluster.OpenBucket(BucketName))
            {
                var queryResult = await DbCluster.QueryAsync <T>("SELECT `" + BucketName + "`.* FROM `" + BucketName + "` WHERE type=\"" + TypeString + "\"");

                if (queryResult.Success)
                {
                    return(queryResult.Rows);
                }

                return(new List <T>());
            }
        }
Exemple #2
0
        protected async Task Delete(Guid id)
        {
            var classTypeString = typeof(T).Name;
            var idString        = DocumentPrefix + classTypeString + "::" + id.ToString();

            using (var bucket = DbCluster.OpenBucket(BucketName))
            {
                var insert = await bucket.RemoveAsync(idString);

                if (insert.Success)
                {
                    Console.WriteLine("Removed " + idString);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine(insert.Status.ToString());
                }
            }
        }
Exemple #3
0
        protected async Task Put(int id, [FromBody] T item)
        {
            var model           = item as BaseModel;
            var classTypeString = typeof(T).Name;
            var idString        = DocumentPrefix + classTypeString + "::" + model.Id.ToString();

            using (var bucket = DbCluster.OpenBucket(BucketName))
            {
                var insert = await bucket.UpsertAsync(idString, item);

                if (insert.Success)
                {
                    Console.WriteLine("Updated " + idString);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine(insert.Status.ToString());
                }
            }
        }