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