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