예제 #1
0
        public WriteResult Update(string key, string value)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                return(WriteResult.Failure("Key parameter is missing"));
            }

            if (string.IsNullOrWhiteSpace(value))
            {
                return(WriteResult.Failure("Value parameter is missing"));
            }

            var oldValue = Find <string>(key);

            if (oldValue.IsSuccess)
            {
                var isSuccess = storage.TryUpdate(key, value, oldValue.Value);
                return(WriteResult.Success($"Value '{oldValue.Value}' with '{key}' updated with new value '{value}'"));
            }
            else
            {
                return(WriteResult.Failure(oldValue.Message));
            }
        }