Example #1
0
        public HomeModule()
        {
            Get["/"] = _ =>
            {
                List <Bills_PC> AllPokemon = Bills_PC.GetAll();
                return(View["index.cshtml", AllPokemon]);
            };

            Post["/pc"] = _ =>
            {
                Bills_PC newEntry = new Bills_PC(Request.Form["dex-no"], Request.Form["name"], Request.Form["nick-name"], Request.Form["lv"]);
                newEntry.Save();
                List <Bills_PC> AllPokemon = Bills_PC.GetAll();
                return(View["index.cshtml", AllPokemon]);
            };

            Post["/DeleteAll"] = _ =>
            {
                Bills_PC.DeleteAll();
                List <Bills_PC> AllPokemon = Bills_PC.GetAll();
                return(View["index.cshtml", AllPokemon]);
            };

            Post["/release"] = _ =>
            {
                foreach (string pokemon in Request.Form["pokemon"])
                {
                    Bills_PC.DeleteOne(pokemon);
                }
                List <Bills_PC> AllPokemon = Bills_PC.GetAll();
                return(View["index.cshtml", AllPokemon]);
            };
        }
Example #2
0
        public void Test_Save()
        {
            Bills_PC testPokemon = new Bills_PC(001, "Bulbasaur", "Sprite", 11);

            testPokemon.Save();
            List <Bills_PC> result = Bills_PC.GetAll();

            Console.WriteLine(result[0].GetDex() + " " + result[0].GetName() + " " + result[0].GetNick() + " " + result[0].GetLv());
            string resultTest = "Bulbasaur";

            Assert.Equal(resultTest, result[0].GetName());
        }