Ejemplo n.º 1
0
        public async Task <IActionResult> DeleteComfirmed(int id)
        {
            Clothing c = await ClothingDB.GetClothingbyID(id, _context);

            await ClothingDB.Delete(id, _context);

            TempData["Message"] = $"{c.Title} deleted successfully";
            return(RedirectToAction(nameof(ShowAll)));
        }
        // Add a single product to the shopping cart
        public async Task <IActionResult> Add(int id, string prevUrl)
        {
            Clothing c = await ClothingDB.GetClothingbyID(id, _context);

            if (c != null)
            {
                CartHelper.Add(c, _accessor);
            }

            return(Redirect(prevUrl));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(BadRequest());
            }

            //Return same view with validation messages
            Clothing c = await ClothingDB.GetClothingbyID(id.Value, _context);

            if (c == null) // Clothing not in DB
            {
                // Returns a HTTP 404 - Not Found
                return(NotFound());
            }

            return(View(c));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Delete(int id)
        {
            Clothing c = await ClothingDB.GetClothingbyID(id, _context);

            return(View(c));
        }