Exemplo n.º 1
0
    public void onClick()
    {
        SimpleInventoryItem newI = InventoryItemFactory.factory.buildSimpleItemTest();

        if (newI == null)
        {
            Debug.Log("Nocab flag -1");
        }
        ic.addItem(newI);
    }
Exemplo n.º 2
0
        public async Task <ActionResult <List <SimpleInventoryItem> > > GetAllInventories([FromHeader] string Authorization)
        {
            int userId = await uow.UserDb.GetPpUserIdByJWT(Authorization);

            var inventories    = uow.Users.GetInventoriesWithUser((int)userId).ToList();
            var inventoryItems = new List <SimpleInventoryItem>();

            //Combine 4 list to one list
            foreach (var inventory in inventories)
            {
                foreach (var item in inventory.ItemCollection)
                {
                    var simpleItem = new SimpleInventoryItem(item);
                    inventoryItems.Add(simpleItem);
                }
            }
            return(inventoryItems);
        }
Exemplo n.º 3
0
        public async Task <ActionResult <List <SimpleInventoryItem> > > Get(int itemId, [FromHeader] string Authorization)
        {
            var ids = await uow.UserDb.GetInventoryIdsByJwt(Authorization);

            if (itemId == null)
            {
                return(BadRequest());
            }
            if (_context.InventoryItem.Any(ii => ii.ItemId == itemId) == false)
            {
                return(NotFound());
            }
            var inIts = new List <SimpleInventoryItem>();

            foreach (var id in ids)
            {
                var inIt = await _context.InventoryItem
                           .Include(ii => ii.Item)
                           .Include(ii => ii.Inventory)
                           .Where(ii => ii.ItemId == itemId)
                           .Where(ii => ii.InventoryId == id).FirstOrDefaultAsync();

                if (inIt != null)
                {
                    var simpleInventoryItem = new SimpleInventoryItem(inIt);
                    //simpleInventoryItem.InventoryType=ConvertTypeToEnum(inIt.Inventory.GetType());
                    inIts.Add(simpleInventoryItem);
                }
            }

            if (inIts == null)
            {
                return(NotFound());
            }
            //Copy content into simple class (JSON converter complains about too many references)
            //List<SimpleInventoryItem> simpleList = new List<SimpleInventoryItem>();
            //foreach (var ii in inIts)
            //{
            //    simpleList.Add(new SimpleInventoryItem(ii) { InventoryType = ConvertTypeToEnum(ii.Inventory) });

            //}
            return(inIts);
        }
Exemplo n.º 4
0
        public async Task CreateWExistingItem_IIalreadyCreatedToday_OriginalIsIncemted()
        {
            try
            {
                //uut.CreateWNewItem(null, 1, ii, "Bearer " + jwt);
                var ii = new SimpleInventoryItem()
                {
                    Amount = 3,
                    ItemId = 2
                };
                var result = await uut.CreateWExistingItem(null, 3, ii, "Bearer " + jwt);

                result = await uut.CreateWExistingItem(null, 3, ii, "Bearer " + jwt);

                var result1 = await uut.Get(2, "Bearer " + jwt);

                Assert.That(result1.Value.Count, Is.EqualTo(2));//Two II already exists with seed data
                Assert.That(result1.Value[1].Amount, Is.EqualTo(10));
            }
            finally
            {
                dbc.Dispose();
            }
        }