public virtual void Modify(ref ValidationErrors errors, Apps.Models.Sys.SysStructModel model, params string[] updateProperties) { SysStruct 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.ParentId = model.ParentId; entity.Sort = model.Sort; entity.Higher = model.Higher; entity.Enable = model.Enable; entity.Remark = model.Remark; entity.CreateTime = model.CreateTime; } else { Type type = typeof(Apps.Models.Sys.SysStructModel); Type typeE = typeof(Apps.Models.SysStruct); 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); }
public virtual void Create(ref ValidationErrors errors, Apps.Models.Sys.SysStructModel model) { SysStruct entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return; } entity = new SysStruct(); entity.Id = model.Id; entity.Name = model.Name; entity.ParentId = model.ParentId; entity.Sort = model.Sort; entity.Higher = model.Higher; entity.Enable = model.Enable; entity.Remark = model.Remark; entity.CreateTime = model.CreateTime; m_Rep.Create(entity); }
public virtual Apps.Models.Sys.SysStructModel GetById(string id) { SysStruct entity = m_Rep.GetById(id); if (entity != null) { //SysStruct entity = m_Rep.GetById(id); Apps.Models.Sys.SysStructModel model = new Apps.Models.Sys.SysStructModel(); model.Id = entity.Id; model.Name = entity.Name; model.ParentId = entity.ParentId; model.Sort = entity.Sort; model.Higher = entity.Higher; model.Enable = entity.Enable; model.Remark = entity.Remark; model.CreateTime = entity.CreateTime; return(model); } else { return(null); } }