[HttpDelete("{id}")] // ./api/customers/:id public IActionResult Delete(int id) { var customer = _customerData.Get(id); if (customer == null) { return(NotFound()); } _customerData.Delete(customer); _customerData.Commit(); return(NoContent()); }
public ActionResult Delete(int id, Customer customer) { try { // TODO: Add delete logic here db.Delete(db.Get(id)); return(RedirectToAction("Index")); } catch { return(Delete(id)); } }
public IActionResult OnPost(int id) { var temp = customerData.Delete(id); if (temp == null) { return(RedirectToPage("./NotFound")); } customerData.Commit(); TempData["TempMessage"] = "The customer is deleted!"; return(RedirectToPage("./List")); }
public IActionResult Delete(Customer customer) { var temp = customerData.Delete(customer.Id); if (temp == null) { return(RedirectToAction("NotFound")); } customerData.Commit(); TempData["TempMessage"] = "The customer is deleted!"; return(RedirectToAction("List")); }
[HttpDelete("{id}")] // ./api/customers/:id public IActionResult Delete(int id) { var customer = _customerData.Get(id); if (customer == null) { _logger.LogWarning("Customer {0} not found", id); return(NotFound()); } _logger.LogInformation("Deleting customer: {0}", id); _customerData.Delete(customer); _customerData.Commit(); return(NoContent()); }
[HttpDelete("{id}")] // ./api/customers/:id public IActionResult Delete(int id) { var customer = _customerData.Get(id); if (customer == null) { _logger.LogWarning("Customer {0} not found", id); return(NotFound()); } // TODO: ensure User owns this customer record, else return 403. _logger.LogInformation("Deleting customer: {0}", id); _customerData.Delete(customer); _customerData.Commit(); return(NoContent()); }