public void Models_SelectedFactoryInventoryForStudentViewModel_Default_Instantiate_Should_Pass()
        {
            // Act
            var result = new SelectedFactoryInventoryForStudentViewModel();

            // Assert
            Assert.IsNotNull(result, TestContext.TestName);
        }
Beispiel #2
0
        /// <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));
        }