Ejemplo n.º 1
0
        /// <summary>
        /// 根据学生ID获取相关联系人信息
        /// </summary>
        /// <param name="id">学生ID</param>
        /// <returns></returns>
        public ViewResult GetContactList(Guid id)
        {
            StudentInfoEntity   studentInfo = repository.StudentInfo.FirstOrDefault(s => s.StudentID == id);
            StudentParentEntity fatherInfo  = repository.StudentParent.FirstOrDefault(s => s.StudentID == id && s.PersonIdentity == PersonIdentity.父亲);
            StudentParentEntity motherInfo  = repository.StudentParent.FirstOrDefault(s => s.StudentID == id && s.PersonIdentity == PersonIdentity.母亲);
            StudentParentEntity otherInfo   = repository.StudentParent.FirstOrDefault(s => s.StudentID == id && s.PersonIdentity == PersonIdentity.其他);

            if (fatherInfo != null)
            {
                ViewBag.FatherId = fatherInfo.ParentID;
            }
            if (motherInfo != null)
            {
                ViewBag.MotherId = motherInfo.ParentID;
            }
            if (otherInfo != null)
            {
                ViewBag.OtherId = otherInfo.ParentID;
            }
            ViewBag.StudentId = id;
            return(View());
        }
Ejemplo n.º 2
0
        public JsonResult FirstRegFormInfo(StudentCreateModel ajaxData)
        {
            StudentInfoEntity  studentInfo = ajaxData.StudentInfo;
            AppRelationsEntity appRelation = repository.AppRelations.SingleOrDefault(a => a.StudentID == studentInfo.StudentID);

            StudentParentEntity parent = null;

            if (ajaxData.ContactStudent != null)
            {
                studentInfo.Mobile = ajaxData.ContactStudent.ContactIdentity.Mobile;
                studentInfo.Email  = ajaxData.ContactStudent.ContactIdentity.Email;
            }
            repository.SaveStudentInfo(studentInfo, appRelation);   //保存StudentInfo以及AppRelation信息

            if (ajaxData.ContactStudent.EasyChatTimes != null)
            {
                foreach (EasyChatTimeEntity item in ajaxData.ContactStudent.EasyChatTimes)
                {
                    item.IfStudentID = studentInfo.StudentID;
                    repository.SaveEasyChatTime(item);      //保存方便联系时间
                }
            }

            if (ajaxData.ContactFather != null)
            {
                parent = repository.StudentParent.SingleOrDefault(s => s.StudentID == studentInfo.StudentID && s.PersonIdentity == PersonIdentity.父亲);
                if (parent != null)
                {
                    parent.NameCn = ajaxData.ContactFather.ContactIdentity.NameCn;
                    parent.Mobile = ajaxData.ContactFather.ContactIdentity.Mobile;
                    parent.Email  = ajaxData.ContactFather.ContactIdentity.Email;
                    repository.SaveStudentParent(parent);
                    if (ajaxData.ContactFather.EasyChatTimes != null)
                    {
                        foreach (EasyChatTimeEntity item in ajaxData.ContactFather.EasyChatTimes)
                        {
                            item.IfParentID = parent.ParentID;
                            repository.SaveEasyChatTime(item);  //添加EasyChatTime信息
                        }
                    }
                }
                else
                {
                    AddParentAndChattime(ajaxData.ContactFather, studentInfo.StudentID);
                }
            }
            if (ajaxData.ContactMother != null)
            {
                parent = repository.StudentParent.SingleOrDefault(s => s.StudentID == studentInfo.StudentID && s.PersonIdentity == PersonIdentity.母亲);
                if (parent != null)
                {
                    parent.NameCn = ajaxData.ContactMother.ContactIdentity.NameCn;
                    parent.Mobile = ajaxData.ContactMother.ContactIdentity.Mobile;
                    parent.Email  = ajaxData.ContactMother.ContactIdentity.Email;
                    repository.SaveStudentParent(parent);
                    if (ajaxData.ContactMother.EasyChatTimes != null)
                    {
                        foreach (EasyChatTimeEntity item in ajaxData.ContactMother.EasyChatTimes)
                        {
                            item.IfParentID = parent.ParentID;
                            repository.SaveEasyChatTime(item);  //添加EasyChatTime信息
                        }
                    }
                }
                else
                {
                    AddParentAndChattime(ajaxData.ContactMother, studentInfo.StudentID);
                }
            }
            if (ajaxData.ContactOther != null)
            {
                parent = repository.StudentParent.SingleOrDefault(s => s.StudentID == studentInfo.StudentID && s.PersonIdentity == PersonIdentity.其他);
                if (parent != null)
                {
                    parent.NameCn = ajaxData.ContactOther.ContactIdentity.NameCn;
                    parent.Mobile = ajaxData.ContactOther.ContactIdentity.Mobile;
                    parent.Email  = ajaxData.ContactOther.ContactIdentity.Email;
                    repository.SaveStudentParent(parent);
                    if (ajaxData.ContactOther.EasyChatTimes != null)
                    {
                        foreach (EasyChatTimeEntity item in ajaxData.ContactOther.EasyChatTimes)
                        {
                            item.IfParentID = parent.ParentID;
                            repository.SaveEasyChatTime(item);  //添加EasyChatTime信息
                        }
                    }
                }
                else
                {
                    AddParentAndChattime(ajaxData.ContactOther, studentInfo.StudentID);
                }
            }

            return(Json(new { InfoResult = true, StudentID = studentInfo.StudentID }));
        }