コード例 #1
0
        public virtual void Modify(ref ValidationErrors errors, Apps.Models.Sys.SysPositionModel model, params string[] updateProperties)
        {
            SysPosition 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.Remark      = model.Remark;
                entity.Sort        = model.Sort;
                entity.CreateTime  = model.CreateTime;
                entity.Enable      = model.Enable;
                entity.MemberCount = model.MemberCount;
                entity.DepId       = model.DepId;
            }
            else
            {
                Type type  = typeof(Apps.Models.Sys.SysPositionModel);
                Type typeE = typeof(Apps.Models.SysPosition);
                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);
        }
コード例 #2
0
        public virtual void Create(ref ValidationErrors errors, Apps.Models.Sys.SysPositionModel model)
        {
            SysPosition entity = m_Rep.GetById(model.Id);

            if (entity != null)
            {
                errors.Add(Resource.PrimaryRepeat);
                return;
            }
            entity             = new SysPosition();
            entity.Id          = model.Id;
            entity.Name        = model.Name;
            entity.Remark      = model.Remark;
            entity.Sort        = model.Sort;
            entity.CreateTime  = model.CreateTime;
            entity.Enable      = model.Enable;
            entity.MemberCount = model.MemberCount;
            entity.DepId       = model.DepId;

            m_Rep.Create(entity);
        }
コード例 #3
0
        public virtual Apps.Models.Sys.SysPositionModel GetById(string id)
        {
            SysPosition entity = m_Rep.GetById(id);

            if (entity != null)
            {
                //SysPosition entity = m_Rep.GetById(id);
                Apps.Models.Sys.SysPositionModel model = new Apps.Models.Sys.SysPositionModel();
                model.Id          = entity.Id;
                model.Name        = entity.Name;
                model.Remark      = entity.Remark;
                model.Sort        = entity.Sort;
                model.CreateTime  = entity.CreateTime;
                model.Enable      = entity.Enable;
                model.MemberCount = entity.MemberCount;
                model.DepId       = entity.DepId;

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