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); } }
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); }
public NccSettings Save(NccSettings entity) { _entityRepository.Add(entity); _entityRepository.SaveChange(); return(entity); }