public ActionResult UpdateRebel([FromBody] Rebel rebel) { var message = ""; _log.LogInformation("Init UpdateRebel"); try { if (!ModelState.IsValid) { throw new InvalidDataException("The rebel entered is not valid"); } var rebelUpdated = _rebelService.UpdateRebel(rebel); _log.LogInformation("Rebel updated successfully"); return(Ok(rebelUpdated)); } catch (InvalidDataException e) { message = "InvalidDataException: " + e.Message; _log.LogError(message); } catch (Exception e) { message = "Exception trying to UpdateRebel: " + e.Message; _log.LogError(message); } finally { _log.LogInformation("Finish UpdateRebel"); } return(BadRequest(message)); }
public IActionResult Update([FromBody] RebelParams rebel) { try { if (rebel != null) { _rebelService.UpdateRebel(rebel); _logger.LogInformation("Rebel Updated in the system"); return(Ok()); } else { return(NotFound()); } } catch (Exception ex) { _logger.LogError($"Failed to update the rebel: {ex}"); } return(BadRequest("Failed to update the rebel")); }