public async Task <IActionResult> Edit(int id)
        {
            Product p = await ProductDb.GetProductByIdAsync(_context, id);

            // Pass product to view
            return(View(p));
        }
        /// <summary>
        /// Adds a product to the shopping cart
        /// </summary>
        /// <param name="id">The id of the product to add</param>
        /// <returns></returns>
        public async Task <IActionResult> Add(int id) // Id of the product to add
        {
            // Get product from the DB
            Product p = await ProductDb.GetProductByIdAsync(_context, id);

            CookieHelper.AddProductToCart(p, _httpContext);

            // Redirect back to previous page
            return(RedirectToAction("Index", "Product"));
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            Product p = await ProductDb.GetProductByIdAsync(_context, id);

            _context.Entry(p).State = EntityState.Deleted;

            await _context.SaveChangesAsync();

            TempData["Message"] = $"{p.Title} was deleted.";

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Delete(int id)
        {
            Product p = await ProductDb.GetProductByIdAsync(_context, id);

            return(View(p));
        }