Example #1
0
        /// <summary>
        /// 创建实体
        /// </summary>
        /// <param name="saveType"></param>
        /// <returns></returns>
        public virtual CustomerEntity CreateEntity(SaveType saveType)
        {
            var entity = new CustomerEntity
            {
                Name = string.IsNullOrWhiteSpace(Name) ? "" : Name,
                Type = new CustomerTypeEntity {
                    Id = TypeId.Convert <long>()
                },
                Channel = new CustomerChannelEntity {
                    Id = TypeId.Convert <long>()
                },
                Gender    = string.IsNullOrWhiteSpace(Gender) ? "" : Gender,
                Qq        = string.IsNullOrWhiteSpace(Qq) ? "" : Qq,
                Linkman   = string.IsNullOrWhiteSpace(Linkman) ? "" : Linkman,
                Weixin    = string.IsNullOrWhiteSpace(Weixin) ? "" : Weixin,
                Mobile    = string.IsNullOrWhiteSpace(Mobile) ? "" : Mobile,
                Telephone = string.IsNullOrWhiteSpace(Telephone) ? "" : Telephone,
                Email     = string.IsNullOrWhiteSpace(Email) ? "" : Email,
                Address   = string.IsNullOrWhiteSpace(Address) ? "" : Address,
                Remark    = string.IsNullOrWhiteSpace(Remark) ? "" : Remark,
                SaveType  = saveType
            };

            entity.RemindNoteDate = string.IsNullOrWhiteSpace(RemindNoteDate)
                ? entity.GetMinDateTime()
                : RemindNoteDate.Convert <DateTime>();
            if (saveType == SaveType.Modify)
            {
                entity.Id = Id.Convert <long>();
                if (Name != null)
                {
                    entity.SetProperty(it => it.Name);
                }
                if (TypeId != null)
                {
                    entity.SetProperty(it => it.Type.Id);
                }
                if (ChannelId != null)
                {
                    entity.SetProperty(it => it.Channel.Id);
                }
                if (Gender != null)
                {
                    entity.SetProperty(it => it.Gender);
                }
                if (Qq != null)
                {
                    entity.SetProperty(it => it.Qq);
                }
                if (Linkman != null)
                {
                    entity.SetProperty(it => it.Linkman);
                }
                if (Weixin != null)
                {
                    entity.SetProperty(it => it.Weixin);
                }
                if (Mobile != null)
                {
                    entity.SetProperty(it => it.Mobile);
                }
                if (Telephone != null)
                {
                    entity.SetProperty(it => it.Telephone);
                }
                if (Email != null)
                {
                    entity.SetProperty(it => it.Email);
                }
                if (Address != null)
                {
                    entity.SetProperty(it => it.Address);
                }
                if (Remark != null)
                {
                    entity.SetProperty(it => it.Remark);
                }
                if (RemindNoteDate != null)
                {
                    entity.SetProperty(it => it.RemindNoteDate);
                }
            }
            return(entity);
        }