public virtual void Modify(ref ValidationErrors errors, Apps.Models.SCV.CUSTOM.CUSTOM_RESOURCE_MODEL model, params string[] updateProperties) { Apps.Models.CUSTOM_RESOURCE entity = m_Rep.GetById(model.RESOURCE_KEY); if (entity == null) { errors.Add(Resource.Disable); return; } if (updateProperties.Count() <= 0) { entity.RESOURCE_KEY = model.RESOURCE_KEY; entity.LOCALE = model.LOCALE; entity.RESOURCE_TYPE = model.RESOURCE_TYPE; entity.RESOURCE_TEXT = model.RESOURCE_TEXT; } else { Type type = typeof(Apps.Models.SCV.CUSTOM.CUSTOM_RESOURCE_MODEL); Type typeE = typeof(Apps.Models.CUSTOM_RESOURCE); 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.SCV.CUSTOM.CUSTOM_RESOURCE_MODEL model) { Apps.Models.CUSTOM_RESOURCE entity = m_Rep.GetById(model.RESOURCE_KEY); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return; } entity = new Apps.Models.CUSTOM_RESOURCE(); entity.RESOURCE_KEY = model.RESOURCE_KEY; entity.LOCALE = model.LOCALE; entity.RESOURCE_TYPE = model.RESOURCE_TYPE; entity.RESOURCE_TEXT = model.RESOURCE_TEXT; m_Rep.Create(entity); }
public virtual Apps.Models.SCV.CUSTOM.CUSTOM_RESOURCE_MODEL GetById(string id) { Apps.Models.CUSTOM_RESOURCE entity = m_Rep.GetById(id); if (entity != null) { //CUSTOM_RESOURCE entity = m_Rep.GetById(id); Apps.Models.SCV.CUSTOM.CUSTOM_RESOURCE_MODEL model = new Apps.Models.SCV.CUSTOM.CUSTOM_RESOURCE_MODEL(); model.RESOURCE_KEY = entity.RESOURCE_KEY; model.LOCALE = entity.LOCALE; model.RESOURCE_TYPE = entity.RESOURCE_TYPE; model.RESOURCE_TEXT = entity.RESOURCE_TEXT; return(model); } else { return(null); } }