public IActionResult AddToCart(int countin) { /// <summary> /// Adds order item view model to cart /// </summary> Customer thisCustomer = (Customer)_cache.Get("thisCustomer"); StockItemViewModel vSt = (StockItemViewModel)_cache.Get("currentViewedStock"); if (!UtilMethods.CheckProductCount(vSt.LocationId, vSt.ProductId, countin, _context)) { StockItemViewModel thisSIVM = (StockItemViewModel)_cache.Get("currentViewedStock"); return(Redirect($"/Home/ProductSelect?locid={thisSIVM.LocationId}&prodid={thisSIVM.ProductId}&ovarload=true")); } double totalPrice = vSt.Price * countin; OrderItemViewModel thisOrder = new OrderItemViewModel( thisCustomer.CustomerId, vSt.LocationId, vSt.ProductId, $"{thisCustomer.FirstName} {thisCustomer.LastName}", vSt.ProductName, countin, UtilMethods.TrimPriceDigits(totalPrice), vSt.LocationAddress, DateTime.Now); List <OrderItemViewModel> CurrentCart = (List <OrderItemViewModel>)_cache.Get("customerCart"); CurrentCart.Add(thisOrder); _cache.Set("customerCart", CurrentCart); return(Redirect("/Home/Cart")); }