예제 #1
0
        public bool CreateKey(string key, string value, out string message)
        {
            var existingKey = _entityRepository.GetByKey(key);

            if (existingKey != null)
            {
                message = "Key already exists. Please use another key";
                return(false);
            }
            else
            {
                _entityRepository.Add(new NccSettings()
                {
                    Key = key, Value = value
                });
                _entityRepository.SaveChange();
                message = "Create successful";
                return(true);
            }
        }
예제 #2
0
        public NccSettings SetByKey(string key, string value)
        {
            var settings = _entityRepository.Query().FirstOrDefault(x => x.Key == key);

            if (settings != null)
            {
                settings.Value = value;
                _entityRepository.Edit(settings);
            }
            else
            {
                settings = new NccSettings()
                {
                    Key = key, Value = value
                };
                _entityRepository.Add(settings);
            }
            _entityRepository.SaveChange();

            return(settings);
        }
예제 #3
0
 public NccSettings Save(NccSettings entity)
 {
     _entityRepository.Add(entity);
     _entityRepository.SaveChange();
     return(entity);
 }