Пример #1
0
        /// <summary>
        /// Build out the View used by Edit.
        /// If anything is wrong, don't init the studentID.
        /// </summary>
        /// <param name="studentId"></param>
        /// <param name="InventoryId"></param>
        /// <param name="defaultUri"></param>
        public ShopTruckItemViewModel GetShopTruckItemViewModel(string studentId, string inventoryId)
        {
            /*
             * Pass in the inventory Id for the Item.
             *
             * Retrieve the Id item
             *
             * Put the returned Factory Item in the Item Slot
             *
             * Get the Category
             *
             * Get the StudentId Inventory
             *
             * Find all the Items that match the Category
             *
             * Add them to the Item List
             *
             */

            var data = new ShopTruckItemViewModel();

            if (string.IsNullOrEmpty(studentId))
            {
                return(null);
            }

            if (string.IsNullOrEmpty(inventoryId))
            {
                return(null);
            }

            var InventoryData = DataSourceBackend.Instance.FactoryInventoryBackend.Read(inventoryId);

            if (InventoryData == null)
            {
                return(null);
            }

            var StudentData = DataSourceBackend.Instance.StudentBackend.Read(studentId);

            if (StudentData == null)
            {
                return(null);
            }

            var InventoryListData = StudentData.Inventory.Where(m => m.Category == InventoryData.Category).ToList();

            // Found the Item, and Found the Inventory List for the Item
            data.Item     = InventoryData;
            data.ItemList = InventoryListData;

            return(data);
        }
        public void Models_ShopTruckItemViewModel_Default_Instantiate_Should_Pass()
        {
            // Arrange

            // Act
            var result = new ShopTruckItemViewModel();

            // Reset
            DataSourceBackend.Instance.Reset();

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