コード例 #1
0
 public IActionResult Delete(int?sportId)
 {
     try
     {
         if (sportId.HasValue)
         {
             var dbRecord = _sportService.Find(sportId);
             if (dbRecord == null)
             {
                 _logger.LogError("delet" +
                                  "e operation failed");
                 return(BadRequest("Record not found"));
             }
             else
             {
                 _logger.LogInformation("Record successfully deleted ", dbRecord);
                 _sportService.delete(sportId);
                 return(Ok("Record successfully deleted"));
             }
         }
         else
         {
             return(BadRequest("Invalid Id submited, request failed"));
         }
     }
     catch (Exception ex)
     {
         _logger.LogError("An error occured ", ex);
         return(BadRequest($"There was an error while processing your request {ex}"));
     }
 }