public async Task <IActionResult> Locations() { /// <summary> /// The store list page /// </summary> ViewData["cartcount"] = UtilMethods.GetCartCount(_cache); return(View(await _context.Locations.ToListAsync())); }
public IActionResult Error() { /// <summary> /// Error message page /// </summary> ViewData["cartcount"] = UtilMethods.GetCartCount(_cache); return(View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier })); }
public IActionResult Index() { /// <summary> /// The main user menu /// </summary> if (!UtilMethods.LogInCheck(_cache)) { return(Redirect("/Login")); } ViewData["cartcount"] = UtilMethods.GetCartCount(_cache); return(View()); }
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)); }
public async Task <IActionResult> StoreHistory(int?id) { /// <summary> /// The store order history 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 foundOrderItems = from thisTableItem in _context.OrderItems where thisTableItem.LocationId == thisLocation.LocationId select thisTableItem; List <OrderItem> theseOrderItems = foundOrderItems.ToList <OrderItem>(); List <OrderItemViewModel> theseOrderItemViewModels = new List <OrderItemViewModel>(); foreach (OrderItem thisOrderItem in theseOrderItems) { Customer thisCustomer = await _context.Customers .FirstOrDefaultAsync(m => m.CustomerId == thisOrderItem.CustomerId); OrderItemViewModel thisOrderItemViewModel = UtilMethods.BuildOrderItemViewModelFromCustOrder(thisCustomer, thisOrderItem, _context); theseOrderItemViewModels.Add(thisOrderItemViewModel); } ViewData["storeaddress"] = thisLocation.LocationAddress; ViewData["cartcount"] = UtilMethods.GetCartCount(_cache); return(View(theseOrderItemViewModels)); }
public IActionResult History() { /// <summary> /// User order history page /// </summary> if (!UtilMethods.LogInCheck(_cache)) { return(Redirect("/Login")); } Customer thisCustomer = (Customer)_cache.Get("thisCustomer"); var foundOrderItems = _context.OrderItems.Where(m => m.CustomerId == thisCustomer.CustomerId); List <OrderItem> theseOrderItems = foundOrderItems.ToList <OrderItem>(); List <OrderItemViewModel> theseOrderItemViewModels = new List <OrderItemViewModel>(); foreach (OrderItem thisOrderItem in theseOrderItems) { OrderItemViewModel thisOrderItemViewModel = UtilMethods.BuildOrderItemViewModelFromCustOrder(thisCustomer, thisOrderItem, _context); theseOrderItemViewModels.Add(thisOrderItemViewModel); } ViewData["userName"] = $"{thisCustomer.FirstName} {thisCustomer.LastName}"; ViewData["cartcount"] = UtilMethods.GetCartCount(_cache); return(View(theseOrderItemViewModels)); }
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)); }