Exemple #1
0
        public virtual void Modify(ref ValidationErrors errors, Apps.Models.Sys.SysUserConfigModel model, params string[] updateProperties)
        {
            SysUserConfig entity = m_Rep.GetById(model.Id);

            if (entity == null)
            {
                errors.Add(Resource.Disable);
                return;
            }
            if (updateProperties.Count() <= 0)
            {
                entity.Id     = model.Id;
                entity.Name   = model.Name;
                entity.Value  = model.Value;
                entity.Type   = model.Type;
                entity.State  = model.State;
                entity.UserId = model.UserId;
            }
            else
            {
                Type type  = typeof(Apps.Models.Sys.SysUserConfigModel);
                Type typeE = typeof(Apps.Models.SysUserConfig);
                foreach (var item in updateProperties)
                {
                    System.Reflection.PropertyInfo pi  = type.GetProperty(item);
                    System.Reflection.PropertyInfo piE = typeE.GetProperty(item);
                    piE.SetValue(entity, pi.GetValue(model), null);
                }
            }


            m_Rep.Modify(entity, updateProperties);
        }
Exemple #2
0
        public virtual void Create(ref ValidationErrors errors, Apps.Models.Sys.SysUserConfigModel model)
        {
            SysUserConfig entity = m_Rep.GetById(model.Id);

            if (entity != null)
            {
                errors.Add(Resource.PrimaryRepeat);
                return;
            }
            entity        = new SysUserConfig();
            entity.Id     = model.Id;
            entity.Name   = model.Name;
            entity.Value  = model.Value;
            entity.Type   = model.Type;
            entity.State  = model.State;
            entity.UserId = model.UserId;

            m_Rep.Create(entity);
        }
Exemple #3
0
        public virtual Apps.Models.Sys.SysUserConfigModel GetById(string id)
        {
            SysUserConfig entity = m_Rep.GetById(id);

            if (entity != null)
            {
                //SysUserConfig entity = m_Rep.GetById(id);
                Apps.Models.Sys.SysUserConfigModel model = new Apps.Models.Sys.SysUserConfigModel();
                model.Id     = entity.Id;
                model.Name   = entity.Name;
                model.Value  = entity.Value;
                model.Type   = entity.Type;
                model.State  = entity.State;
                model.UserId = entity.UserId;

                return(model);
            }
            else
            {
                return(null);
            }
        }