示例#1
0
        public async Task <IActionResult> Delete(int id)
        {
            var location = GetControllerActionNames();

            try
            {
                _logger.LogInfo($"{location}: Delete Attempted on record with id: {id} ");
                if (id < 1)
                {
                    _logger.LogWarn($"{location}: Delete failed with bad data - id: {id}");
                    return(BadRequest());
                }

                var result = await _businessLogic.Delete(id);

                if (result.IsFailed)
                {
                    return(InternalError($"{location}: Delete failed for record with id: {id}"));
                }

                _logger.LogInfo($"{location}: Record with id: {id} successfully deleted");
                return(NoContent());
            }
            catch (Exception e)
            {
                return(InternalError($"{location}: {e.Message} - {e.InnerException}"));
            }
        }
示例#2
0
 public IActionResult Delete([FromBody] Customer customer)
 {
     if (customer.Id > 0)
     {
         return(Ok(_logic.Delete(customer)));
     }
     return(BadRequest());
 }
示例#3
0
 public IActionResult Delete([FromBody] Customer customer)
 {
     if (customer.Id > 0)
     {
         return(Ok(_logic.Delete(customer)));
     }
     return(BadRequest(new { Message = "Has ocurred during the customer deleted" }));
 }
        public async Task <IActionResult> DeleteCustomer([FromRoute] int id)
        {
            try
            {
                await _customersLogic.Delete(id);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }