public static void Update()
        {
            WoWEntities db = new WoWEntities();

            if (db.Realms.Count() == 0)
            {
                RealmStatusList realms = ApiClient.GetRealms();
                foreach (RealmDescription realm in realms.Realms)
                {
                    db.Realms.Add(new Realm() { Battlegroup = realm.Battlegroup, Name = realm.Name, Population = realm.Population, Queue = realm.Queue, Slug = realm.Slug, Status = realm.Status });
                }
                db.SaveChanges();
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("a: Auction Update");
            Console.WriteLine("c: Characters");
            Console.WriteLine("d: Db Tweak");
            Console.WriteLine("p: Pet Update");
            Console.WriteLine("s: Scrape");
            Console.WriteLine("j: Get JSON");
            Console.WriteLine("k: Ackis Parser");
            ConsoleKeyInfo ck = Console.ReadKey();
            switch (ck.KeyChar) {
                case 'a':
                    using (WoWEntities ctx = new WoWEntities())
                    {
                        foreach (string realm in ctx.Characters.Select(a => a.Realm).Select(b => b.Slug).Distinct())
                        {
                            AuctionUpdater.UpdateAuctionValues(realm);
                        }
                    }
                    break;
                case 'c':
                    CharacterUpdater.RefreshCharacters();
                    break;
                case 'd':
                    DbTweak.Tweak();
                    break;
                case 'p':
                    PetParser.Parse();
                    break;
                case 's':
                    Scraper.Scrape();
                    break;
                case 'j':
                    JSONGetter.GetMissingJSON();
                    break;
                case 'k':
                    AckisParser.Parse();
                    break;
            }

            Console.WriteLine("Done!");
            Console.ReadKey();
        }
        private static void UpdateCharacter(string name, string realm)
        {
            Console.WriteLine("Fetching " + name);

            using (WoWEntities db = new WoWEntities())
            {
                var character = ApiClient.GetCharacter(name, realm);
                WoWModel.Character dbcharacter = db.Characters.SingleOrDefault(a => a.Name == name);
                if (dbcharacter == null)
                {
                    dbcharacter = new WoWModel.Character();
                    db.Characters.Add(new WoWModel.Character {
                        Name = character.Name,
                        AchievementPoints = character.AchievementPoints,
                        ClassId = character.ClassId,
                        Gender = character.Gender,
                        LastModified = character.LastModified,
                        Level = character.Level,
                        RaceId = character.Race,
                        Realm = db.Realms.Single(a => a.Name == realm), Thumbnail = character.Thumbnail });
                    db.SaveChanges();
                    dbcharacter = db.Characters.Single(a => a.Name == name);
                }
                dbcharacter.AchievementPoints = character.AchievementPoints;
                dbcharacter.Class = db.Classes.Single(a => a.ClassId == character.ClassId);
                dbcharacter.Gender = character.Gender;
                dbcharacter.LastModified = character.LastModified;
                dbcharacter.Level = character.Level;
                dbcharacter.Name = character.Name;
                dbcharacter.Race = db.Races.Single(a => a.RaceId == character.Race);
                dbcharacter.Realm = db.Realms.Single(a => a.Name == character.Realm);
                dbcharacter.Thumbnail = character.Thumbnail;

                List<int> knownTradeskills = dbcharacter.Tradeskills.Select(a => a.TradeskillId).ToList();
                foreach (var tradeskillId in character.Professions.Primary.Select(a => a.Id).Where(b => !knownTradeskills.Contains(b)))
                {
                    dbcharacter.Tradeskills.Add(db.Tradeskills.Single(a => a.TradeskillId == tradeskillId));
                }
                foreach (var tradeskillId in character.Professions.Secondary.Select(a => a.Id).Where(b => !knownTradeskills.Contains(b)))
                {
                    dbcharacter.Tradeskills.Add(db.Tradeskills.Single(a => a.TradeskillId == tradeskillId));
                }

                List<int> knownRecipes = dbcharacter.Recipes.Select(a => a.RecipeId).ToList();

                foreach (Profession profession in character.Professions.Primary.Concat(character.Professions.Secondary))
                {
                    foreach (int recipeId in profession.Recipes)
                    {
                        if (!knownRecipes.Contains(recipeId))
                        {
                            WoWModel.Recipe recipe = db.Recipes.SingleOrDefault(a => a.RecipeId == recipeId);
                            if (recipe == null)
                            {
                                Console.WriteLine("Error: Recipe " + recipeId + " not found");
                            }
                            else
                            {
                                dbcharacter.Recipes.Add(recipe);
                            }
                        }
                    }
                }
                //foreach (var recipeid in character.Professions.Primary.SelectMany(profession => profession.Recipes).Where(recipeid => !knownRecipes.Contains(recipeid)))
                //{
                //    dbcharacter.Recipes.Add(db.Recipes.Single(a => a.RecipeId == recipeid));
                //}

                //foreach (var recipeid in character.Professions.Secondary.SelectMany(profession => profession.Recipes).Where(recipeid => !knownRecipes.Contains(recipeid)))
                //{
                //    dbcharacter.Recipes.Add(db.Recipes.Single(a => a.RecipeId == recipeid));
                //}

                //List<int> knownPets = dbcharacter.Companions.Select(a => a.CompanionId).ToList();

                //foreach (var companionId in character.Companions.Where(companionId => !knownPets.Contains(companionId)))
                //{
                //    if (!db.Companions.Any(a => a.CompanionId == companionId))
                //    {
                //        db.Companions.AddObject(new Companion() { CompanionId = companionId, Name = "Companion" + companionId });
                //        db.SaveChanges();
                //    }
                //    dbcharacter.Companions.Add(db.Companions.Single(b => b.CompanionId == companionId));
                //}

                db.SaveChanges();
            }
        }
        public static void Parse()
        {
            List<string> potentialRecipes = new List<string>();
            using (StreamReader r = new StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\Collectinator\Database\PetDatabase.lua"))
            {
                string line;
                StringBuilder currentToken = new StringBuilder();
                while ((line = r.ReadLine()) != null)
                {
                    if (Regex.Match(line, @"-- .*").Success) // save out current buffer and start on next
                    {
                        potentialRecipes.Add(currentToken.ToString());
                        currentToken = new StringBuilder();
                        currentToken.Append(line);
                    }
                    else
                    {
                        currentToken.Append(line);
                    }
                }
            }

            Regex nameIdRegex = new Regex(@"-- ([^\n]+) - (\d+)\s+AddPet\(\d+, (\d+)");
            Regex nameIdRegex2 = new Regex(@"-- ([^\n]+) -- (\d+)\s+AddPet\(\d+, (\d+)");
            Regex nameIdRegex3 = new Regex(@"-- ([^\n]+)\s+AddPet\((\d+), (\d+)");
            //  -- Tranquil Mechanical Yeti - 26010
            //AddPet(26010, 21277, R_COMMON, GAME_ORIG)
            using (WoWEntities db = new WoWEntities())
            {
                foreach (var pc in potentialRecipes)
                {
                    Match spellMatch = nameIdRegex.Match(pc);
                    if (!spellMatch.Success)
                    {
                        spellMatch = nameIdRegex2.Match(pc);
                        if (!spellMatch.Success)
                        {
                            spellMatch = nameIdRegex3.Match(pc);
                        }
                    }

                    if (spellMatch.Success)
                    {
                        string name = spellMatch.Groups[1].ToString();
                        Console.WriteLine(name);
                        int spellId = Convert.ToInt32(spellMatch.Groups[2].ToString());
                        int itemId = Convert.ToInt32(spellMatch.Groups[3].ToString());

                        if (!db.Companions.Any(a => a.CompanionId == spellId))
                        {
                            db.Companions.Add(new Companion { CompanionId = spellId, Name = name });
                            db.SaveChanges();
                        }
                        else
                        {
                            db.Companions.Single(a => a.CompanionId == spellId).Name = name;
                            db.SaveChanges();
                        }

                        //db.Items.Single(a => a.ItemId == itemId).CompanionTaught = db.Companions.Single(a => a.CompanionId == spellId);
                        db.SaveChanges();
                    }
                }
            }
        }