예제 #1
0
        public virtual Apps.Models.Spl.Spl_PersonModel GetById(string id)
        {
            Spl_Person entity = m_Rep.GetById(id);

            if (entity != null)
            {
                //Spl_Person entity = m_Rep.GetById(id);
                Apps.Models.Spl.Spl_PersonModel model = new Apps.Models.Spl.Spl_PersonModel();
                model.Id         = entity.Id;
                model.Name       = entity.Name;
                model.Sex        = entity.Sex;
                model.Age        = entity.Age;
                model.IDCard     = entity.IDCard;
                model.Phone      = entity.Phone;
                model.Email      = entity.Email;
                model.Address    = entity.Address;
                model.CreateTime = entity.CreateTime;
                model.Region     = entity.Region;
                model.Category   = entity.Category;

                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        public virtual void Modify(ref ValidationErrors errors, Apps.Models.Spl.Spl_PersonModel model, params string[] updateProperties)
        {
            Spl_Person 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.Sex        = model.Sex;
                entity.Age        = model.Age;
                entity.IDCard     = model.IDCard;
                entity.Phone      = model.Phone;
                entity.Email      = model.Email;
                entity.Address    = model.Address;
                entity.CreateTime = model.CreateTime;
                entity.Region     = model.Region;
                entity.Category   = model.Category;
            }
            else
            {
                Type type  = typeof(Apps.Models.Spl.Spl_PersonModel);
                Type typeE = typeof(Apps.Models.Spl_Person);
                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);
        }
예제 #3
0
        public virtual void Create(ref ValidationErrors errors, Apps.Models.Spl.Spl_PersonModel model)
        {
            Spl_Person entity = m_Rep.GetById(model.Id);

            if (entity != null)
            {
                errors.Add(Resource.PrimaryRepeat);
                return;
            }
            entity            = new Spl_Person();
            entity.Id         = model.Id;
            entity.Name       = model.Name;
            entity.Sex        = model.Sex;
            entity.Age        = model.Age;
            entity.IDCard     = model.IDCard;
            entity.Phone      = model.Phone;
            entity.Email      = model.Email;
            entity.Address    = model.Address;
            entity.CreateTime = model.CreateTime;
            entity.Region     = model.Region;
            entity.Category   = model.Category;

            m_Rep.Create(entity);
        }