public IActionResult SetKeyValue([FromBody] Key key) { try { if (key == null) { return(BadRequest(ModelState)); } if (!_keysService.SetKeyValue(key)) { ModelState.AddModelError("", $"Something went wrong seting key pair value"); return(StatusCode(500, ModelState)); } return(Ok(key)); } catch (Exception e) { return(BadRequest(e)); } }
public IActionResult SetKeyValue([FromBody] Key key) { try { if (key == null) { return(BadRequest(ModelState)); } if (!_keysService.SetKeyValue(key)) { ModelState.AddModelError("", $"Something went wrong seting key pair value"); return(StatusCode(500, ModelState)); } var message = new { success = true, message = $"Successfully added {key.KeyName}" }; return(Ok(message)); } catch (Exception e) { return(BadRequest(e)); } }