public IActionResult Buy(int shoppingCartId, Item item) { // This checks if the model's state matches what the database has. if (ModelState.IsValid) { // the itemId is set to zero by default item.Id = 0; // The buy item method is called from the repository. _repo.BuyItem(shoppingCartId, item); // It returns back to the home index return(RedirectToAction("Index", "Home")); } // The buy item page is displayed return(View(item)); }