[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));
     }
 }
示例#3
0
        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"));
        }
示例#4
0
        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());
        }
示例#6
0
        [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());
        }