// GET: FactoryInventory /// <summary> /// Index, the page that shows all the FactoryInventorys /// </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 FactoryInventoryList var myData = new FactoryInventoryListViewModel(); // Get the Inventory var InventoryList = DataSourceBackend.Instance.FactoryInventoryBackend.Index(); // Sort the Inventory into List per Category // Load the ones foreach (var item in Enum.GetValues(typeof(FactoryInventoryCategoryEnum))) { var temp = new FactoryInventoryViewModel { Category = (FactoryInventoryCategoryEnum)item, FactoryInventoryList = InventoryList.Where(m => m.Category == (FactoryInventoryCategoryEnum)item).ToList() }; if (temp.FactoryInventoryList.Any()) { // todo, tag the ones that are already owned myData.FactoryInventoryCategoryList.Add(temp); } } return(View(myData)); }
public void Models_FactoryInventoryViewModel_Default_Instantiate_Should_Pass() { // Act var result = new FactoryInventoryViewModel(); // Assert Assert.IsNotNull(result, TestContext.TestName); }
/// <summary> /// What to Buy at the store /// </summary> /// <returns></returns> // GET: Buy public ActionResult Factory(string id = null) { // Temp hold the Student Id for the Nav, until the Nav can call for Identity. ViewBag.StudentId = id; // Load the list of data into the FactoryInventoryList var myData = new SelectedFactoryInventoryForStudentViewModel(); // Get the Student var myStudent = DataSourceBackend.Instance.StudentBackend.Read(id); if (myStudent == null) { return(RedirectToAction("Error", "Home")); } myData.Student = myStudent; // Get the Inventory var InventoryList = DataSourceBackend.Instance.FactoryInventoryBackend.Index(); // Sort the Inventory into List per Category // Load the ones foreach (var item in Enum.GetValues(typeof(FactoryInventoryCategoryEnum))) { var temp = new FactoryInventoryViewModel { Category = (FactoryInventoryCategoryEnum)item, FactoryInventoryList = InventoryList.Where(m => m.Category == (FactoryInventoryCategoryEnum)item).ToList() }; if (temp.FactoryInventoryList.Any()) { // todo, tag the ones that are already owned myData.FactoryInventoryCategoryList.Add(temp); } } return(View(myData)); }