Exemple #1
0
        public static void InsertCrime(string type, string name, int jailTime, int fine)
        {
            var crime = new Crime(type, name, jailTime, fine)
            {
                Id = DatabaseManager.GetNextId("crimes")
            };

            crime.Insert();
            Crimes.Add(crime);
        }
Exemple #2
0
        public static void UpdateCrimes()
        {
            foreach (var crime in DatabaseManager.CrimeTable.Find(FilterDefinition <Crime> .Empty).ToList())
            {
                var filter = Builders <Crime> .Filter.Eq("Id", crime.Id);

                DatabaseManager.CrimeTable.DeleteOne(filter);
            }

            foreach (var setCrime in Crimes)
            {
                var InsertCrime = new Crime(setCrime.Type, setCrime.Name, setCrime.JailTime, setCrime.Fine)
                {
                    Id = DatabaseManager.GetNextId("crimes")
                };
                InsertCrime.Insert();
            }
        }