/// <summary>
        /// adds item to wish to vist list
        /// </summary>
        /// <param name="id"></param>
        /// <param name="previosUrl"></param>
        /// <returns></returns>
        public async Task <IActionResult> AddWishToVisit(int id, string previosUrl)
        {
            // Get product from the database
            ParkModel p = await ParkDB.GetProductAsync(_context, id);

            // redirct back to prevoius page
            return(Redirect(previosUrl));
        }
Beispiel #2
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            ParkModel p = await ParkDB.GetProductAsync(_context, id);

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

            await _context.SaveChangesAsync();

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

            return(RedirectToAction("Index"));
        }
        /// <summary>
        /// Adds item to visited list
        /// </summary>
        /// <param name="id"></param>
        /// <param name="previosUrl"></param>
        /// <returns></returns>
        public async Task <IActionResult> AddVisited(int id, string previosUrl)
        {
            // Get product from the database
            ParkModel p = await ParkDB.GetProductAsync(_context, id);

            List <ParkModel> parks = CookieHelper.GetCartProducts(_httpContext);

            // stops same park from ebing added again
            if (parks.Contains(p))
            {
                TempData["Message"] = p.ParkName + " was already added successfully";
            }
            else
            {
                CookieHelper.AddProductToCart(_httpContext, p);
                TempData["Message"] = p.ParkName + " was added successfully";
            }
            // redirct back to prevoius page
            return(Redirect(previosUrl));
        }
Beispiel #4
0
        public async Task <IActionResult> Edit(int id)
        {
            ParkModel p = await ParkDB.GetProductAsync(_context, id);

            return(View(p));
        }