Exemple #1
0
 public IEnumerable <Category> GetCategories()
 {
     using (var db = _databaseProvider.CreateDatabase())
     {
         var collection = db.GetCollection <Category>(nameof(Category));
         return(collection.FindAll().OrderBy(x => x.Id));
     }
 }
 public Gradient GetById(int id)
 {
     using (var db = _databaseProvider.CreateDatabase())
     {
         var collection = db.GetCollection <Gradient>(nameof(Gradient));
         return(collection.FindById(new BsonValue(id)));
     }
 }
Exemple #3
0
        public List <Category> GetCategories()
        {
            using (var db = _databaseProvider.CreateDatabase())
            {
                var collection = db.GetCollection <Category>(nameof(Category));
                var result     = collection.FindAll()
                                 .OrderBy(x => x.Id)
                                 .ToList();

                var gradients = db.GetCollection <Gradient>();

                foreach (var cat in result)
                {
                    cat.Count = gradients.Count(x => x.Tags.Contains(cat.Tag));
                }

                return(result);
            }
        }
        public void RunUpdate(params ICanUpdateMyself[] repositories)
        {
            var metadata = _documentRepository.GetDocument <Metadata>("Playground.Data.Resources.Metadata.json");

            using (var db = _databaseProvider.CreateDatabase())
            {
                if (db.Engine.UserVersion >= metadata.Version)
                {
                    return;
                }

                foreach (var repository in repositories)
                {
                    repository.UpdateDatabase(db, metadata, _documentRepository);
                }

                db.Engine.UserVersion = metadata.Version;
            }
        }