コード例 #1
0
        public async Task <IActionResult> ProductSelect(string locid = "", string prodid = "", string ovarload = "false")
        {
            /// <summary>
            /// The specific product selection page
            /// </summary>
            if (!UtilMethods.LogInCheck(_cache))
            {
                return(Redirect("/Login"));
            }
            if (locid == "")
            {
                return(Redirect("/Locations"));
            }
            int thisLocId = int.Parse(locid);

            if (prodid == "")
            {
                return(Redirect($"/LocationDetails/{thisLocId}"));
            }
            int thisProdId   = int.Parse(prodid);
            var thisLocation = await _context.Locations
                               .FirstOrDefaultAsync(m => m.LocationId == thisLocId);

            var thisProduct = await _context.Products
                              .FirstOrDefaultAsync(m => m.ProductId == thisProdId);

            var thisStockItem = await _context.StockItems
                                .FirstOrDefaultAsync(m => m.LocationId == thisLocId && m.ProductId == thisProdId);

            if (thisLocation == null || thisProduct == null || thisStockItem == null)
            {
                return(NotFound());
            }
            if (ovarload == "true")
            {
                ViewData["warn"] = "toomuch";
            }
            StockItemViewModel thisStockItemViewModel = UtilMethods.BuildStockItemViewModelFromLocStock(thisLocation, thisStockItem, _context);

            _cache.Set("currentViewedStock", thisStockItemViewModel);
            ViewData["cartcount"] = UtilMethods.GetCartCount(_cache);
            return(View(thisStockItemViewModel));
        }
コード例 #2
0
        public async Task <IActionResult> LocationDetails(int?id)
        {
            /// <summary>
            /// The store stocks page
            /// </summary>
            if (id == null)
            {
                return(NotFound());
            }
            int thisLocId = (int)id;

            if (!UtilMethods.LogInCheck(_cache))
            {
                return(Redirect("/Login"));
            }
            var thisLocation = await _context.Locations
                               .FirstOrDefaultAsync(m => m.LocationId == thisLocId);

            if (thisLocation == null)
            {
                return(NotFound());
            }
            var foundStockItems = from thisTableItem in _context.StockItems
                                  where thisTableItem.LocationId == thisLocation.LocationId
                                  select thisTableItem;
            List <StockItem>          theseStockItems          = foundStockItems.ToList <StockItem>();
            List <StockItemViewModel> theseStockItemViewModels = new List <StockItemViewModel>();

            foreach (StockItem thisStockItem in theseStockItems)
            {
                StockItemViewModel thisStockItemViewModel = UtilMethods.BuildStockItemViewModelFromLocStock(thisLocation, thisStockItem, _context);
                theseStockItemViewModels.Add(thisStockItemViewModel);
            }
            ViewData["cartcount"] = UtilMethods.GetCartCount(_cache);
            return(View(theseStockItemViewModels));
        }