Exemplo n.º 1
0
        public IActionResult AllItems(ItemViewModel ivm)
        {
            if (HttpContext.Session.GetString("Username") != "Admin")
            {
                return(RedirectToAction("Index", "Home"));
            }
            ivm.AllItems = new List <ItemViewModel>();
            foreach (Item item in _ir.GetAllItems(ivm.Sortingtype))
            {
                ivm.AllItems.Add(ItemToItemVM.ToItemVM(item));
            }

            return(View(ivm));
        }
Exemplo n.º 2
0
        public IActionResult LoadMap(int characterID)
        {
            if (HttpContext.Session.GetString("Username") == null)
            {
                return(RedirectToAction("Login", "Account"));
            }
            var tempItemList = new List <ItemViewModel>();

            foreach (Item item in _ir.GetAllItems(0))
            {
                tempItemList.Add(ItemToItemVM.ToItemVM(item));
            }
            var mvm = new MapViewModel
            {
                character = CharacterToCharacterVM.ToCharVM(_cr.GetById(characterID)),
                allitems  = tempItemList
            };

            return(View("Game", mvm));
        }
Exemplo n.º 3
0
        public void TestLoadingGame()
        {
            //Arrange
            CharacterCreationViewModel ccvm = new CharacterCreationViewModel();
            ICharacterContext          _Icc = new TestCharacterContext();
            IItemContext  _IIc         = new TestItemContext();
            CharacterRepo _cr          = new CharacterRepo(_Icc);
            ItemRepo      _ir          = new ItemRepo(_IIc);
            var           mvm          = new MapViewModel();
            var           tempItemList = new List <ItemViewModel>();

            //Act

            mvm.character = CharacterToCharacterVM.ToCharVM(_cr.GetById(5));
            foreach (Item item in _ir.GetAllItems(0))
            {
                tempItemList.Add(ItemToItemVM.ToItemVM(item));
            }
            mvm.allitems = tempItemList;
            //Assert
            Assert.IsTrue(mvm.character != null && mvm.character.CharacterModel != "");
            Assert.IsTrue(mvm.allitems.Count > 0);
        }