Exemplo n.º 1
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);       //如果数据库中没有对应身份的联系人记录,则添加
                }
            }
        }
Exemplo n.º 2
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信息
                }
            }
        }
Exemplo n.º 3
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信息
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 返回EasyChatTimeModel
        /// </summary>
        /// <param name="identity">身份</param>
        /// <param name="nameCn">中文名</param>
        /// <param name="email">邮箱</param>
        /// <param name="mobile">电话</param>
        /// <param name="personId">id</param>
        /// <returns></returns>
        public EasyChatTimeModel ReturnEasyChatTimeModel(PersonIdentity identity, string nameCn, string email, string mobile, Guid personId)
        {
            EasyChatTimeModel returnModel = new EasyChatTimeModel();
            ContactIdentity   contact     = new ContactIdentity
            {
                PersonIdentity = identity.ToString(),
                NameCn         = nameCn,
                Email          = email,
                Mobile         = mobile
            };
            IEnumerable <EasyChatTimeEntity> easyChatTimes = null;

            if (identity == PersonIdentity.学生)
            {
                easyChatTimes = repository.EasyChatTime.Where(e => e.IfStudentID == personId).Select(e => e);
            }
            else
            {
                easyChatTimes = repository.EasyChatTime.Where(e => e.IfParentID == personId).Select(e => e);
            }

            returnModel.ContactIdentity = contact;
            returnModel.EasyChatTimes   = easyChatTimes;
            return(returnModel);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 渲染初访登记表——学生信息与联系时间
        /// </summary>
        /// <param name="id">学生ID</param>
        /// <returns></returns>
        public ViewResult FirstRegFormInfo(Guid id)
        {
            StudentInfoEntity studentInfo = repository.StudentInfo.SingleOrDefault(s => s.StudentID == id);

            if (studentInfo.NationIntention == null)
            {
                studentInfo.NationIntention = string.Empty;
            }

            StudentCreateModel regFromInfo = new StudentCreateModel
            {
                StudentInfo = studentInfo,
                AppRelation = repository.AppRelation.SingleOrDefault(a => a.StudentID == studentInfo.StudentID)
            };

            StudentParentEntity father = repository.StudentParent.SingleOrDefault(s => s.StudentID == id && s.PersonIdentity == PersonIdentity.父亲);
            StudentParentEntity mother = repository.StudentParent.SingleOrDefault(s => s.StudentID == id && s.PersonIdentity == PersonIdentity.母亲);
            StudentParentEntity other  = repository.StudentParent.SingleOrDefault(s => s.StudentID == id && s.PersonIdentity == PersonIdentity.其他);

            EasyChatTimeModel contactFather  = null;
            EasyChatTimeModel contactMother  = null;
            EasyChatTimeModel contactOther   = null;
            EasyChatTimeModel contactStudent = null;

            if (studentInfo != null)
            {
                contactStudent             = ReturnEasyChatTimeModel(PersonIdentity.学生, studentInfo.NameCn, studentInfo.Email, studentInfo.Mobile, studentInfo.StudentID);
                regFromInfo.ContactStudent = contactStudent;
            }
            if (father != null)
            {
                contactFather             = ReturnEasyChatTimeModel(father.PersonIdentity, father.NameCn, father.Email, father.Mobile, father.ParentID);
                regFromInfo.ContactFather = contactFather;
            }
            if (mother != null)
            {
                contactMother             = ReturnEasyChatTimeModel(mother.PersonIdentity, mother.NameCn, mother.Email, mother.Mobile, mother.ParentID);
                regFromInfo.ContactMother = contactMother;
            }
            if (other != null)
            {
                contactOther             = ReturnEasyChatTimeModel(other.PersonIdentity, other.NameCn, other.Email, other.Mobile, other.ParentID);
                regFromInfo.ContactOther = contactOther;
            }

            return(View(regFromInfo));
        }
Exemplo n.º 6
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));
        }