示例#1
0
        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));
            }
        }
示例#2
0
        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));
            }
        }