示例#1
0
        private MonstersService CreateMonstersService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId()); // Gets the user's ID when the data is created
            var service = new MonstersService(userId);           // Creates the new monster under their userID // 8.02

            return(service);
        }
示例#2
0
        // GET: Monsters
        public ActionResult Index()                              // Show the user their specific monsters
        {
            var userId  = Guid.Parse(User.Identity.GetUserId()); // Sets userId to the GUID of the logged in user
            var service = new MonstersService(userId);           // Sets service to the user's list of monsters they created
            var model   = service.GetMonsters();                 // Gets the user's list of monsters

            return(View(model));                                 // Returns the user's list of monsters
        }
示例#3
0
        private static async Task GetMonsters()
        {
            string          saveLocation = Path.Combine(Directory.GetCurrentDirectory(), "Monsters");
            MonstersService monsters     = new MonstersService(saveLocation);

            try
            {
                IEnumerable <Monster> creatures = await monsters.GetMonsters(false, true);

                SaveJson(creatures, saveLocation, "monsters");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }