Ejemplo n.º 1
0
        static bool CreateCity()
        {
            string input = "";

            Console.WriteLine("enter targeted city details (name, population)");
            Console.Write("City ▷");
            input = Console.ReadLine();
            input.ToLower();

            if (input == "q")
            {
                return(true);
            }
            string[] stats = input.Split();
            try {
                string Name = "";
                using (var db = new CADContext())
                {
                    var city = new City {
                        Name = stats[0], Population = int.Parse(stats[1])
                    };
                    db.city.Add(city);
                    db.SaveChanges();
                    Name = city.Name;
                }
                Console.WriteLine("{0} Added", Name);
                return(true);
            }
            catch
            {
                Console.WriteLine("ERROR: Incorrect Values");
                return(false);
            }
        }
Ejemplo n.º 2
0
        static bool CreateCreature()
        {
            string input = "";

            Console.WriteLine("enter creature details (name, threat level 0-?, type)");
            Console.Write("Creature ▷");
            input = Console.ReadLine();
            input.ToLower();

            if (input == "q")
            {
                return(true);
            }
            string[] stats = input.Split();
            try {
                string Name = "";
                using (var db = new CADContext())
                {
                    var creature = new Creature {
                        Name = stats[0], Threat_level = int.Parse(stats[1]), Type = stats[2]
                    };
                    db.creature.Add(creature);
                    db.SaveChanges();
                    Name = creature.Name;
                }

                Console.WriteLine("{0} Added", Name);
                return(true);
            }
            catch
            {
                Console.WriteLine("ERROR: Incorrect Values");
                return(false);
            }
        }
Ejemplo n.º 3
0
 static void PrintAllCities()
 {
     using (var db = new CADContext())
     {
         var cities = db.city.ToList();
         Console.WriteLine("all targeted cities: ");
         foreach (City city in cities)
         {
             Console.WriteLine("{0} {1}", city.Name, city.Population);
         }
     }
 }
Ejemplo n.º 4
0
 static void PrintAllCreatures()
 {
     Console.WriteLine("all known creatures: ");
     using (var db = new CADContext())
     {
         var creatures = db.creature.ToList();
         foreach (Creature creature in creatures)
         {
             Console.WriteLine("{0} {1} {2}", creature.Name, creature.Threat_level, creature.Type);
         }
     }
 }
Ejemplo n.º 5
0
        static bool CreateRampage()
        {
            string input = "";

            Console.WriteLine("enter rampage details (creature, city, date MM DD YYYY)");
            Console.Write("Rampage ▷");
            input = Console.ReadLine();
            input.ToLower();

            if (input == "q")
            {
                return(true);
            }
            string[] stats = input.Split();

            using (var db = new CADContext())
            {
                var creature = db.creature.Where(b => b.Name == stats[0]).FirstOrDefault();
                var city     = db.city.Where(b => b.Name == stats[1]).FirstOrDefault();

                if (creature == null)
                {
                    Console.WriteLine("Creature not registered to CAD");
                    return(false);
                }

                if (city == null)
                {
                    Console.WriteLine("City not registered to CAD");
                    return(false);
                }

                try {
                    DateTime date    = new DateTime(int.Parse(stats[4]), int.Parse(stats[2]), int.Parse(stats[3]));
                    Rampage  rampage = new Rampage {
                        Creature_id = creature.Id, City_id = city.Id, Status = "Ongoing", Date = date, Damages = 0
                    };
                    db.rampage.Add(rampage);
                    db.SaveChanges();
                    Console.WriteLine("Rampage Logged as an ongoing event");
                    return(true);
                }
                catch
                {
                    Console.WriteLine("ERROR: Incorrect Values");
                    return(false);
                }
            }
        }