Exemplo n.º 1
0
        public IActionResult Index(string q)
        {
            ViewBag.SearchTargets = new List <string>
            {
                "Alle",
                "Bücher",
                "Zeitschriften",
                "Magazine",
            };

            if (string.IsNullOrEmpty(q))
            {
                return(View());
            }

            var articles   = _article.SearchForArticlesByMatchcode(q);
            var articleIds = articles.Select(x => x.ArticleId).ToArray();
            var invItems   = _inventory.FindInventoryItemsByArticleId(articleIds);

            Propagate(articles, invItems);
            SetDefaultImageIfEmpty(articles);
            var searchResult = new SearchResultViewModel
            {
                FoundQuantity = articles.Count(),
                Items         = articles,
            };

            return(View(searchResult));
        }
Exemplo n.º 2
0
        public IActionResult ShowInventoryItems(int id)
        {
            if (id == 0)
            {
                return(RedirectToAction("Index"));
            }

            var inventoryItems = _inventoryProvider.FindInventoryItemsByArticleId(new[] { id });
            var userIds        = inventoryItems.Select(x => x.RentedByUserId);
            var users          = _userProvider.FindByUserIds(userIds);

            PropagateInventoryItemsWithUsers(inventoryItems, users);
            var viewModel = inventoryItems.ToDetailsViewModels();

            return(View(viewModel));
        }