示例#1
0
        private async Task <ShoppingListItem> GetFullItemInfo(ItemShoppingListLinkEntity itemlistlink, int storeId, CancellationToken ct)
        {
            var itemEntity = await _itemRepository.GetEntityAsync(itemlistlink.ItemId, ct);

            SpoonProductInformation spoonItem = GetSpoonItem(itemEntity.SpoonacularProductId);
            var itemStoreLink = await _itemStoreLinkRepository.GetEntityAsync(itemlistlink.ItemId, storeId, ct);

            var department = await _departmentRepository.GetEntityAsync(itemStoreLink.DepartmentId, ct);

            var lowerDepartment = await _lowerDepartmentRepository.GetEntityAsync(itemStoreLink.LowerDepartmentId, ct);

            var aisle = await _aisleRepository.GetEntityAsync(itemStoreLink.AisleId, ct);

            var section = await _sectionRepository.GetEntityAsync(itemStoreLink.SectionId, ct);

            var shelf = await _shelfRepository.GetEntityAsync(itemStoreLink.ShelfId, ct);

            var slot = await _shelfSlotsRepository.GetEntityAsync(itemStoreLink.SlotId, ct);


            ShoppingListItem item = new ShoppingListItem
            {
                LinkId            = itemlistlink.Id,
                Image             = "image.jpg",
                Name              = itemEntity.Name,
                Price             = itemStoreLink.Price,
                InStock           = itemStoreLink.InStock,
                StockAmount       = itemStoreLink.StockAmount,
                ItemQuantity      = itemlistlink.ItemQuantity,
                DepartmentId      = itemStoreLink.DepartmentId,
                Department        = department.Name,
                LowerDepartmentId = itemStoreLink.LowerDepartmentId,
                LowerDepartment   = lowerDepartment.Name,
                AisleId           = itemStoreLink.AisleId,
                Aisle             = aisle.Name,
                SectionId         = itemStoreLink.SectionId,
                Section           = section.Name,
                ShelfId           = itemStoreLink.ShelfId,
                Shelf             = shelf.ShelfNumber.ToString(),
                SlotId            = itemStoreLink.SlotId,
                Slot              = slot.SlotOnShelf.ToString()
            };

            if (spoonItem != null)
            {
                item.Image = spoonItem.images.First();
            }

            return(item);
        }