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