Exemplo n.º 1
0
        /// <summary>
        /// 将联系人信息转成乘车人信息
        /// </summary>
        /// <param name="contactList"></param>
        /// <returns></returns>
        private List <PassengerInfoModel> ConvertContactToPassenger(List <ContactInfoModel> contactList)
        {
            //1.3根据ContactId获取证件信息
            List <PassengerInfoModel> passengerList = new List <PassengerInfoModel>();
            List <int> contactIdList = new List <int>();

            contactList.ForEach(n => contactIdList.Add(n.ContactId));
            List <IdentificationModel> identificationList =
                _identificationInfoBll.GetIdentificationInfoByContactId(contactIdList);

            if (identificationList == null)
            {
                identificationList = new List <IdentificationModel>();
            }


            foreach (ContactInfoModel contactInfo in contactList)
            {
                PassengerInfoModel passengerInfo = new PassengerInfoModel();
                passengerInfo.ContactId          = contactInfo.ContactId;
                passengerInfo.PassengerName      = contactInfo.Name;
                passengerInfo.Mobile             = contactInfo.Mobile;
                passengerInfo.Phone              = contactInfo.Phone;
                passengerInfo.Fax                = contactInfo.Fax;
                passengerInfo.Email              = contactInfo.Email;
                passengerInfo.IdentificationList =
                    identificationList.FindAll(n => n.ContactId == contactInfo.ContactId);
                passengerList.Add(passengerInfo);
            }

            return(passengerList);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 将联系人信息转成乘客信息
        /// </summary>
        /// <returns></returns>
        private List <PassengerInfoModel> ConvertContactToPassenger(List <ContactInfoEntity> contactInfoList, List <CustomerInfoEntity> customerList)
        {
            if (contactInfoList == null || contactInfoList.Count == 0)
            {
                return(null);
            }
            if (contactInfoList.Count > 50)
            {
                contactInfoList = contactInfoList.Take(50).ToList();
            }

            List <PassengerInfoModel> passengerList = new List <PassengerInfoModel>();

            List <int> contactIdList = new List <int>();

            contactInfoList.ForEach(n => contactIdList.Add(n.Contactid));
            List <ContactIdentificationInfoEntity> identificationList =
                _contactIdentificationDal.Query <ContactIdentificationInfoEntity>(
                    n => contactIdList.Contains(n.Contactid)).ToList();

            if (identificationList == null || identificationList.Count == 0)
            {
                identificationList = new List <ContactIdentificationInfoEntity>();
            }

            foreach (ContactInfoEntity contactInfo in contactInfoList)
            {
                PassengerInfoModel passengerInfo = new PassengerInfoModel();
                passengerInfo.ContactId     = contactInfo.Contactid;
                passengerInfo.PassengerName = !string.IsNullOrEmpty(contactInfo.Cname)
                    ? contactInfo.Cname
                    : contactInfo.Ename;
                passengerInfo.Mobile = contactInfo.Mobile;
                passengerInfo.Phone  = contactInfo.Phone;
                passengerInfo.Fax    = contactInfo.Fax;
                passengerInfo.Email  = contactInfo.Email;

                CustomerInfoEntity customerInfoEntity = null;
                if (customerList != null && contactInfo.PCid.HasValue)
                {
                    customerInfoEntity = customerList.Find(n => n.Cid == contactInfo.PCid.Value);
                }
                else
                {
                    customerInfoEntity = customerList?.Find(n => n.Cid == contactInfo.Cid);
                }

                if (customerInfoEntity != null)
                {
                    CorpDepartmentEntity corpDepartmentEntity = _corpDepartmentDal.Find <CorpDepartmentEntity>(customerInfoEntity.CorpDepartID ?? 0);
                    passengerInfo.DepartmentName = corpDepartmentEntity?.DepartName;
                    passengerInfo.Cid            = customerInfoEntity.Cid;
                }


                var tempCardList =
                    identificationList.FindAll(n => n.Contactid == contactInfo.Contactid);
                #region 将默认证件放在首位
                int defaultCardType = contactInfo.DefaultIdentificationId ?? 0;
                var tempCard        = tempCardList.Find(n => n.Iid == defaultCardType);
                if (tempCard != null)
                {
                    tempCardList.RemoveAll(n => n.Iid == defaultCardType);
                    tempCardList = tempCardList.OrderBy(n => n.Iid).ToList();
                    tempCardList.Add(tempCard);
                    tempCardList.Reverse();
                }
                #endregion
                passengerInfo.IdentificationList = Mapper
                                                   .Map <List <ContactIdentificationInfoEntity>, List <IdentificationModel> >(tempCardList);

                passengerList.Add(passengerInfo);
            }

            return(passengerList);
        }