/// <summary> /// store items of the AvatarSelect /// </summary> /// <returns></returns> // GET: Inventory public ActionResult Inventory(string id = null) { // Temp hold the Student Id for the Nav, until the Nav can call for Identity. ViewBag.StudentId = id; var myData = new SelectedAvatarItemListForStudentViewModel(); // Get the Student var myStudent = DataSourceBackend.Instance.StudentBackend.Read(id); if (myStudent == null) { return(RedirectToAction("Error", "Home")); } myData.Student = myStudent; var InventoryList = myStudent.AvatarInventory; 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)); }
// 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)); }
public void Models_AvatarItemViewModel_Default_Instantiate_Should_Pass() { // Act var result = new AvatarItemViewModel(); // Assert Assert.IsNotNull(result, TestContext.TestName); }