public void Update(Contact contact)
        {
            ValidationTool.Load(new ContactRules(), contact);



            _contacDal.Update(contact);
        }
Exemplo n.º 2
0
        public AddResultBaseModel <int> Edit(EditContactModel model)
        {
            ContactInfoEntity contactInfoEntity = _contactDal.Find <ContactInfoEntity>(model.ContactId);

            if (model.Cname.Contains("/"))
            {
                contactInfoEntity.Ename = model.Cname;
                contactInfoEntity.Cname = string.Empty;
            }
            else
            {
                contactInfoEntity.Cname = model.Cname;
                contactInfoEntity.Ename = string.Empty;
            }

            contactInfoEntity.Mobile         = model.Mobile;
            contactInfoEntity.LastUpdateTime = DateTime.Now;
            contactInfoEntity.UpdateOid      = "sys";
            contactInfoEntity.DelTime        = DateTime.Now;
            contactInfoEntity.Email          = model.Email;
            if (!string.IsNullOrEmpty(model.IsDel))
            {
                contactInfoEntity.IsDel = model.IsDel;
            }

            _contactDal.Update(contactInfoEntity);

            ContactIdentificationInfoEntity contactIdentificationInfoEntity =
                _contactIdentificationDal.Query <ContactIdentificationInfoEntity>(
                    n => n.Contactid == model.ContactId && n.Iid == model.Iid, true).FirstOrDefault();

            if (contactIdentificationInfoEntity != null)
            {
                contactIdentificationInfoEntity.Iid            = model.Iid;
                contactIdentificationInfoEntity.CardNo         = model.CardNo;
                contactIdentificationInfoEntity.LastUpdateTime = DateTime.Now;
                _contactIdentificationDal.Update(contactIdentificationInfoEntity);
            }
            else
            {
                _contactIdentificationDal.Insert <ContactIdentificationInfoEntity>(new ContactIdentificationInfoEntity()
                {
                    Contactid      = model.ContactId,
                    CardNo         = model.CardNo,
                    Iid            = model.Iid,
                    LastUpdateTime = DateTime.Now
                });
            }

            return(new AddResultBaseModel <int>()
            {
                IsSuccessed = true, Id = model.ContactId
            });
        }
Exemplo n.º 3
0
 public bool Update(Contact model)
 {
     try
     {
         return(contactDal.Update(model));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
 public IResult Update(Contact contact)
 {
     try
     {
         _contactDal.Update(contact);
         return(new SuccessResult(Messages.SuccessUpdated));
     }
     catch (Exception)
     {
         return(new ErrorResult(Messages.ErrorUpdated));
     }
 }
Exemplo n.º 5
0
 public void ContactUpdate(Contact contact)
 {
     _contactDal.Update(contact);
 }
Exemplo n.º 6
0
 public IResult Update(Contact contact)
 {
     _contactDal.Update(contact);
     return(new SuccessResult("Güncellendi"));
 }
Exemplo n.º 7
0
 public IResult Update(Contact contact)
 {
     _contactDal.Update(contact);
     return(new SuccessResult(Messages.ContactUpdated));
 }
 public void UpdateContact(Contact contact)
 {
     _contactDal.Update(contact);
 }
Exemplo n.º 9
0
 public void Update(Contact entity)
 {
     _contactDal.Update(entity);
 }
Exemplo n.º 10
0
 public void ContactUpdate(Contact contact)
 {
     _Contactdal.Update(contact);
 }
Exemplo n.º 11
0
        public bool PostIdentification(IdentificationModel model, int cid)
        {
            var contact = _contactDal.Query <ContactInfoEntity>(a => a.PCid == cid).FirstOrDefault();

            if (contact == null)
            {
                throw new Exception("当前客户信息异常,不能修改");
            }

            if (model.IsDefault == 1)
            {
                contact.DefaultIdentificationId = model.Iid;
                _contactDal.Update <ContactInfoEntity>(contact, new string[] { "DefaultIdentificationId" });
            }
            else
            {
                if (contact.DefaultIdentificationId.HasValue && contact.DefaultIdentificationId.Value == model.Iid)
                {
                    contact.DefaultIdentificationId = 0;
                    _contactDal.Update <ContactInfoEntity>(contact, new string[] { "DefaultIdentificationId" });
                }
            }

            model.ContactId = contact.Contactid;
            //判断当前公司下,是否存在相同证件,如果存在,则不许修改
            CustomerModel customerModel = _getCustomerBll.GetCustomerByCid(cid);

            if (!string.IsNullOrEmpty(customerModel.CorpID))
            {
                List <CustomerModel> customerModels = _getCustomerBll.GetCustomerByCorpId(customerModel.CorpID);
                List <int>           cidList        = new List <int>();
                customerModels.ForEach(n =>
                {
                    if (n.Cid != cid)
                    {
                        cidList.Add(n.Cid);
                    }
                });

                List <ContactInfoEntity> contactInfoEntities =
                    _contactDal.Query <ContactInfoEntity>(a => cidList.Contains(a.PCid ?? 0)).ToList();

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

                contactInfoEntities.ForEach(n => contactIdList.Add(n.Contactid));

                List <ContactIdentificationInfoEntity> infoList =
                    _contactIdentificationDal.Query <ContactIdentificationInfoEntity>(
                        n =>
                        contactIdList.Contains(n.Contactid) && !string.IsNullOrEmpty(n.CardNo) &&
                        n.CardNo.ToUpper() == model.CardNo.ToUpper() && n.Iid == model.Iid)
                    .ToList();

                if (infoList != null && infoList.Count > 0)
                {
                    throw new Exception("当前公司存在相同证件号,不能修改");
                }
            }


            var identifications = _contactIdentificationDal.Query <ContactIdentificationInfoEntity>(a => a.Contactid == model.ContactId && a.Iid == model.Iid);
            var entity          = Mapper.Map <IdentificationModel, ContactIdentificationInfoEntity>(model);

            entity.LastUpdateTime = DateTime.Now;
            entity.CardNo         = entity.CardNo ?? "";
            if (identifications != null && identifications.Any())
            {
                _contactIdentificationDal.Update <ContactIdentificationInfoEntity>(entity);
            }
            else
            {
                _contactIdentificationDal.Insert <ContactIdentificationInfoEntity>(entity);
            }
            return(true);
        }
Exemplo n.º 12
0
 public void CategoryUpdate(Contact contact)
 {
     _contactDal.Update(contact);
 }
Exemplo n.º 13
0
 public void Update(Entities.Contact entity)
 {
     _contactDal.Update(entity);
 }
 public Contact Update(Contact contact)
 {
     contact.UserId = PrincipalHelper.GetId();
     return(_contactDal.Update(contact));
 }
Exemplo n.º 15
0
        public bool UpdateCustomerInfo(UpdateCustomerInfoModel up)
        {
            CustomerInfoEntity customerInfoEntity = _customerDal.Find <CustomerInfoEntity>(up.Cid);

            if (customerInfoEntity == null)
            {
                throw new Exception("当前客户信息异常");
            }

            ContactInfoEntity contactInfoEntity = null;

            if (!string.IsNullOrEmpty(customerInfoEntity.CorpID))
            {
                contactInfoEntity =
                    _contactDal.Query <ContactInfoEntity>(n => n.PCid == customerInfoEntity.Cid).FirstOrDefault();

                if (contactInfoEntity == null)
                {
                    throw new Exception("当前客户信息异常,不能修改");
                }
            }

            List <string> upArgsList  = new List <string>();
            List <string> upArgsList2 = new List <string>();

            if (!string.IsNullOrEmpty(up.Email))
            {
                int emailCount =
                    _customerDal.Query <CustomerInfoEntity>(
                        n => n.Email == up.Email && n.Cid != up.Cid && n.CorpID == customerInfoEntity.CorpID, true)
                    .Count();

                if (emailCount > 0)
                {
                    throw new Exception("当前邮箱已经存在,不能修改");
                }

                customerInfoEntity.Email = up.Email;
                upArgsList.Add("Email");

                if (contactInfoEntity != null)
                {
                    contactInfoEntity.Email = up.Email;
                    upArgsList2.Add("Email");
                }
            }

            if (!string.IsNullOrEmpty(up.Gender))
            {
                List <string> genderList = new List <string>()
                {
                    "M", "F"
                };
                if (!genderList.Contains(up.Gender))
                {
                    throw new Exception("性别参数异常,请使用M/F");
                }
                customerInfoEntity.Gender = up.Gender;
                upArgsList.Add("Gender");

                if (contactInfoEntity != null)
                {
                    contactInfoEntity.Gender = up.Gender;
                    upArgsList2.Add("Gender");
                }
            }

            if (!string.IsNullOrEmpty(up.RealName))
            {
                customerInfoEntity.RealName = up.RealName;
                upArgsList.Add("RealName");

                if (contactInfoEntity != null)
                {
                    if (up.RealName.Contains("/"))
                    {
                        contactInfoEntity.Ename = up.RealName;
                        upArgsList2.Add("Ename");
                    }
                    else
                    {
                        contactInfoEntity.Cname = up.RealName;
                        upArgsList2.Add("Cname");
                    }
                }
            }

            if (!string.IsNullOrEmpty(up.Mobile))
            {
                //这里要判断手机号,userid是否唯一
                int mobileCount =
                    _customerDal.Query <CustomerInfoEntity>(
                        n => n.Mobile == up.Mobile && n.Cid != up.Cid && n.CorpID == customerInfoEntity.CorpID, true)
                    .Count();
                if (mobileCount > 0)
                {
                    throw new Exception("当前手机号存在,不能修改");
                }

                int userIdCount =
                    _customerDal.Query <CustomerInfoEntity>(
                        n => n.UserID == up.Mobile && n.Cid != up.Cid && n.CorpID == customerInfoEntity.CorpID, true)
                    .Count();
                if (userIdCount > 0)
                {
                    throw new Exception("当前UserId存在,不能修改");
                }

                customerInfoEntity.Mobile = up.Mobile;
                customerInfoEntity.UserID = up.Mobile;
                upArgsList.Add("Mobile");
                upArgsList.Add("UserID");
                upArgsList2.Add("Mobile");

                if (contactInfoEntity != null)
                {
                    contactInfoEntity.Mobile = up.Mobile;
                    upArgsList2.Add("Mobile");
                }
            }


            _customerDal.Update(customerInfoEntity, upArgsList.ToArray());

            if (contactInfoEntity != null)
            {
                _contactDal.Update(contactInfoEntity, upArgsList2.ToArray());
            }



            return(true);
        }