示例#1
0
        public async Task <IActionResult> Post([FromBody] KeyValue keyValue)
        {
            try
            {
                if (keyValue == null)
                {
                    await Console.Error.WriteLineAsync("keyValue == null");

                    logger.LogError("keyValue == null");
                }
                logger.LogInformation("Post id:{0} value:{1}", keyValue.Id, keyValue.Value);
                await keyValueRepository.AddKeyValueAsync(new KeyValue
                {
                    Id    = keyValue.Id,
                    Value = keyValue.Value
                });

                return(Ok());
            }
            catch (Exception ex)
            {
                logger.LogError("Post {0}", ex.Message);
            }
            return(StatusCode(500));
        }