예제 #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));
        }
예제 #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));
        }
예제 #4
0
        public async Task <IActionResult> Delete(int id)
        {
            Clothing c = await ClothingDB.GetClothingbyID(id, _context);

            return(View(c));
        }