コード例 #1
0
        // GET: AvatarItem
        /// <summary>
        /// Index, the page that shows all the AvatarItems
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var CurrentId = DataSourceBackend.Instance.IdentityBackend.GetCurrentStudentID(HttpContext);

            if (DataSourceBackend.Instance.IdentityBackend.BlockExecptForRole(CurrentId, UserRoleEnum.TeacherUser))
            {
                return(RedirectToAction("Login", "Admin"));
            }

            // Load the list of data into the AvatarItemList
            var myData = new AvatarItemListViewModel();

            // Get the Inventory
            var InventoryList = DataSourceBackend.Instance.AvatarItemBackend.Index();

            // Sort the Inventory into List per Category
            // Load the ones
            foreach (var item in Enum.GetValues(typeof(AvatarItemCategoryEnum)))
            {
                var temp = new AvatarItemViewModel
                {
                    Category       = (AvatarItemCategoryEnum)item,
                    AvatarItemList = InventoryList.Where(m => m.Category == (AvatarItemCategoryEnum)item).ToList()
                };

                if (temp.AvatarItemList.Any())
                {
                    // todo, tag the ones that are already owned
                    myData.AvatarItemCategoryList.Add(temp);
                }
            }

            return(View(myData));
        }
コード例 #2
0
        public void Models_AvatarItemListViewModel_Default_Instantiate_Should_Pass()
        {
            // Act
            var result = new AvatarItemListViewModel();

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }