public virtual Apps.Models.Spl.Spl_ProductModel GetById(string id) { Spl_Product entity = m_Rep.GetById(id); if (entity != null) { //Spl_Product entity = m_Rep.GetById(id); Apps.Models.Spl.Spl_ProductModel model = new Apps.Models.Spl.Spl_ProductModel(); model.Id = entity.Id; model.Name = entity.Name; model.Code = entity.Code; model.Price = entity.Price; model.CostPrice = entity.CostPrice; model.Color = entity.Color; model.Number = entity.Number; model.CategoryId = entity.CategoryId; model.CreateTime = entity.CreateTime; model.CreateBy = entity.CreateBy; return(model); } else { return(null); } }
public virtual void Create(ref ValidationErrors errors, Apps.Models.Spl.Spl_ProductModel model) { Spl_Product entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return; } entity = new Spl_Product(); entity.Id = model.Id; entity.Name = model.Name; entity.Code = model.Code; entity.Price = model.Price; entity.CostPrice = model.CostPrice; entity.Color = model.Color; entity.Number = model.Number; entity.CategoryId = model.CategoryId; entity.CreateTime = model.CreateTime; entity.CreateBy = model.CreateBy; m_Rep.Create(entity); }
public virtual void Modify(ref ValidationErrors errors, Apps.Models.Spl.Spl_ProductModel model, params string[] updateProperties) { Spl_Product 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.Code = model.Code; entity.Price = model.Price; entity.CostPrice = model.CostPrice; entity.Color = model.Color; entity.Number = model.Number; entity.CategoryId = model.CategoryId; entity.CreateTime = model.CreateTime; entity.CreateBy = model.CreateBy; } else { Type type = typeof(Apps.Models.Spl.Spl_ProductModel); Type typeE = typeof(Apps.Models.Spl_Product); 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); }