/// <summary> /// Check if the values in database are contains and they are correct. /// </summary> private void CheckDatabase() { // Check if there are bought animal var animalInUserCollection = _database.GetCollection <BsonDocument>("ANIMAL_IN_USER"); var userCollection = _database.GetCollection <BsonDocument>("USER"); ObjectId idUser = userCollection.FindOne()["_id"].AsObjectId; if (animalInUserCollection.Count() == 0) { Animal animalString = (Animal)0; var an = _database.GetCollection <BsonDocument>("ANIMALS"). Find(new QueryDocument("name", animalString.ToString())); ObjectId idAnimal = new ObjectId(); foreach (var document in an) { idAnimal = document["_id"].AsObjectId; } animalInUserCollection.Insert(new BsonDocument { { "animal_id", idAnimal }, { "user_id", idUser }, { "current", true } }); } // Check if there are current animal if (GetCurrentAnimal() == -1) { DataPlayer data = new DataPlayer(); data.SetDefoultData(); SetCurrentAnimal(data); } }
private void CheckDatabase() { // Check if there are current animal if (GetCurrentAnimal() == -1) { DataPlayer data = new DataPlayer(); data.SetDefoultData(); SetCurrentAnimal(data); } // Check if there are bought animal List <int> boughtAnimals = GetBoughtAnimals(); if (boughtAnimals.Count == 0) { DataPlayer data = new DataPlayer(); data.BoughtAnimals = new List <int>(); data.CurrentAnimal = 0; SetBoughtAnimals(data); } }