public async Task <IActionResult> DeleteConfirmed(int id) { Clothing c = await ClothingDb.GetClothingByID(id, _context); await ClothingDb.Delete(c, _context); TempData["Msg"] = $"{c.Title} Deleted Successfully."; return(RedirectToAction(nameof(ShowAll))); }
public async Task <IActionResult> Delete(int id) { Clothing c = await ClothingDb.GetClothingByID(id, _context); //If id does not exist, go to 404 page if (c == null) { return(NotFound()); } return(View(c)); }
/// <summary> /// Adds a single object to the cart. /// Quantity does not matter if same object added 5 times displayed 5 times. /// </summary> public async Task <IActionResult> AddToCart(int id, string prevUrl) { //Grab the clothing Object by Id. Clothing c = await ClothingDb.GetClothingByID(id, _context); //Add Clothing object to be stored in cookie. if (c != null) { CartHelper.Add(c, _http); } //redirect: sends you back to the url you were previously using return(Redirect(prevUrl)); }
public async Task <IActionResult> Edit(int?id) { if (id == null) { return(BadRequest()); } Clothing c = await ClothingDb.GetClothingByID(id.Value, _context); if (c == null) //Clothing Not in the Db { //returns a Http 404 - Not Found return(NotFound()); } return(View(c)); }