private static void WriteBaseSettingModelValues(BaseSettingModel model, SettingEntity entity)
 {
     model.Name = entity.Name;
     model.Guid = entity.Guid;
     model.SettingKey = entity.SettingKey;
     model.Value = entity.Value;
     model.IsImmutable = entity.IsImmutable;
 }
        public static BaseSettingModel Convert(SettingEntity entity)
        {
            BaseSettingModel model = null;
            if (entity.SettingValueType == SettingValueType.Int)
                model = new IntSettingModel();
            else if (entity.SettingValueType == SettingValueType.Text)
                model = new TextSettingModel();
            else if (entity.SettingValueType == SettingValueType.Select)
                model = new SelectSettingModel()
                {
                    PossibleValues = entity.PossibleValues
                };
            else if (entity.SettingValueType == SettingValueType.TrueOrFalse)
                model = new TrueOrFalseSettingModel()
                {
                    OnContent = entity.OnContent,
                    OffContent = entity.OffContent
                };
            else
                return null;

            WriteBaseSettingModelValues(model, entity);
            return model;
        }
Esempio n. 3
0
 public static void AddSetting(SettingEntity entity)
 {
     var model = EntityModelConverter.Convert(entity);
     AddSetting(model);
 }