Exemple #1
0
        /// <summary>
        /// 编辑Parent及其EasyChatTime
        /// </summary>
        /// <param name="contact"></param>
        /// <param name="studentID"></param>
        void EditParentAndChattime(EasyChatTimeModel contact, Guid studentID)
        {
            PersonIdentity identity = (PersonIdentity)Enum.Parse(typeof(PersonIdentity), contact.ContactIdentity.PersonIdentity);
            //根据联系人身份和学生ID找出数据库中的Parent记录
            StudentParentEntity parent = repository.StudentParent
                .FirstOrDefault(s => s.StudentID == studentID && s.PersonIdentity == identity);

            //联系人信息修改
            parent.NameCn = contact.ContactIdentity.NameCn;
            parent.Mobile = contact.ContactIdentity.Mobile;
            parent.Email = contact.ContactIdentity.Email;
            parent.QQ = contact.ContactIdentity.QQ;
            parent.Weixin = contact.ContactIdentity.Weixin;

            //保存联系人信息
            repository.SaveStudentParent(parent);

            //清空联系人的联系时间
            repository.EmptyContactEasyChatTimes(parent.ParentID);

            //重新添加联系人的联系时间
            if (contact.EasyChatTimes != null)
            {
                foreach (EasyChatTimeEntity item in contact.EasyChatTimes)
                {
                    item.IfParentID = parent.ParentID;
                    repository.SaveEasyChatTime(item);  //添加EasyChatTime信息
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 添加Parent及其EasyChatTime
        /// </summary>
        /// <param name="contact"></param>
        /// <param name="studentID"></param>
        void AddParentAndChattime(EasyChatTimeModel contact, Guid studentID)
        {
            StudentParentEntity other = new StudentParentEntity
            {
                ParentID = Guid.NewGuid(),
                StudentID = studentID,
                NameCn = contact.ContactIdentity.NameCn,
                Email = contact.ContactIdentity.Email,
                Mobile = contact.ContactIdentity.Mobile,
                QQ = contact.ContactIdentity.QQ,
                Weixin = contact.ContactIdentity.Weixin,
                PersonIdentity = (PersonIdentity)Enum.Parse(typeof(PersonIdentity), contact.ContactIdentity.PersonIdentity)
            };
            repository.SaveStudentParent(other);    //添加Parent信息

            if (contact.EasyChatTimes != null)
            {
                foreach (EasyChatTimeEntity item in contact.EasyChatTimes)
                {
                    item.IfParentID = other.ParentID;
                    repository.SaveEasyChatTime(item);  //添加EasyChatTime信息
                }
            }
        }
Exemple #3
0
 /// <summary>
 /// 修改联系人
 /// </summary>
 /// <param name="contact">EasyChatTimeModel类型</param>
 /// <param name="contactIdentity">联系人身份</param>
 /// <param name="studentID"></param>
 void EditContact(EasyChatTimeModel contact, string contactIdentity, Guid studentID)
 {
     PersonIdentity identity = (PersonIdentity)Enum.Parse(typeof(PersonIdentity), contactIdentity);
     //联系人身份
     string personIdentity = contactIdentity;
     if (contact == null)
     {
         if (IsHaveContact(personIdentity, studentID))       //如果数据库中对应身份的联系人记录,则删掉
             repository.RemoveStudentParent(identity, studentID);
     }
     else
     {
         if (IsHaveContact(personIdentity, studentID))       //如果数据库中有对应身份的联系人记录,则修改
             EditParentAndChattime(contact, studentID);
         else
             AddParentAndChattime(contact, studentID);       //如果数据库中没有对应身份的联系人记录,则添加
     }
 }
Exemple #4
0
        public JsonResult EditContacts(EasyChatTimeModel[] Contacts, string studentID)
        {
            bool editResult = true;
            if (studentID == string.Empty || studentID == Guid.Empty.ToString())
            {
                return Json(false);
            }
            Guid id = new Guid(studentID);
            string personIdentity = string.Empty;
            EasyChatTimeModel contactFather = Contacts[0]; ;
            EasyChatTimeModel contactMother = Contacts[1];
            EasyChatTimeModel contactOther = Contacts[2];

            EditContact(contactFather, "父亲", id);
            EditContact(contactMother, "母亲", id);
            EditContact(contactOther, "其他", id);

            return Json(editResult);
        }