Exemple #1
0
        public async Task <IActionResult> DeleteConfirmed(int ID)
        {
            Clothing c = await ClothingDB.GetClothingByID(ID, _context);

            await ClothingDB.Delete(c, _context);

            TempData["Message"] = $"{c.Title} deleted successfully";

            return(RedirectToAction(nameof(InventoryList)));
        }
Exemple #2
0
        public async Task <IActionResult> Delete(int ID)
        {
            Clothing c = await ClothingDB.GetClothingByID(ID, _context);

            if (c == null)
            {
                // returns a HTTP 404 error - Not Found
                return(NotFound());
            }

            return(View(c));
        }
Exemple #3
0
        // 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, _http);
            }

            // Use Redirect instead of RedirectToAction because prevUrl doesn't have an action tied to it
            return(Redirect(prevUrl));
        }
Exemple #4
0
        public async Task <IActionResult> Edit(int?ID)
        {
            if (ID == null)
            {
                // HTTP 400
                return(BadRequest());
            }

            Clothing c = await ClothingDB.GetClothingByID(ID.Value, _context); // .Value can extract data out of a nullable data type

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

            return(View(c));
        }