This is my methods to add some Items to Cart:
[HttpGet("/UserPanel/AddToCart")]
public async Task<IActionResult> ShowCart( )
{
await GetTax();
var cartItems= _siteService.GetFromSession();
var cartViewModel = new CartViewModel
{
Items = cartItems
};
return View(cartViewModel);
}
public async Task<IActionResult> AddToCart(int chefFoodId)
{
var item = await _orderService.GetItemByChefFoodId(chefFoodId);
if (item != null)
{
_siteService.SaveInSession(item);
}
return RedirectToAction("ShowCart");
}
and this is my method in service:
I have add-to-cart icon on my menu , I want to save chefFoodid first in session , and then if user click on cart in header icon, then goes to AddToCard Method
How can I save ChefFoodId in session before going to addToCard method,without script
should I write new method to save chefFoodid in new session? or have another way?