Ejemplo n.º 1
0
        public ActionResult FirstInterview(Guid id)
        {
            StudentInfoEntity studentInfo = repository.StudentInfo.FirstOrDefault(s => s.StudentID == id);
            SaleTrackEntity   SaleTrack;
            IEnumerable <SaleTrackParticipantsEntity> SaleTrackParticipants = null;

            if (repository.SaleTrack.SingleOrDefault(s => s.StudentID == id && s.TrackNo == 1) != null)
            {
                SaleTrack             = repository.SaleTrack.SingleOrDefault(s => s.StudentID == id && s.TrackNo == 1);
                SaleTrackParticipants = repository.SaleTrackParticipants.Where(s => s.SaleTrackID == SaleTrack.TrackItemID).Select(s => s);
            }
            else
            {
                SaleTrack = new SaleTrackEntity
                {
                    TrackItemID  = Guid.NewGuid(),
                    StudentID    = id,
                    Inputor      = "Admin",
                    StateName    = "初访",
                    TrackPattern = TrackPattern.面谈,
                    TrackDate    = studentInfo.CreateTime.AddDays(1),
                    ToDo         = "了解客户需求,完成初访登记表!",
                    IsComplete   = TrackIsComplete.否,
                    Remark       = "请输入备注信息"
                };
                SaleTrackParticipants = Enumerable.Empty <SaleTrackParticipantsEntity>();
            }
            return(View(new SaleTrackViewModel
            {
                StudentInfo = studentInfo,
                SaleTrack = SaleTrack,
                SaleTrackParticipants = SaleTrackParticipants,
                AdditionalIdentity = SaleParticipantIdentity.咨询顾问
            }));
        }
Ejemplo n.º 2
0
        JsonResult GetFirstInterviewData(Guid id)
        {
            StudentInfoEntity  studentInfo = repository.StudentInfo.FirstOrDefault(s => s.StudentID == id);
            AppRelationsEntity appRelation = repository.AppRelation.FirstOrDefault(a => a.StudentID == id);
            SaleTrackEntity    SaleTrack;
            IEnumerable <SaleTrackParticipantsEntity> SaleTrackParticipants = null;

            if (repository.SaleTrack.SingleOrDefault(s => s.StudentID == id && s.TrackNo == 1) != null)
            {
                SaleTrack             = repository.SaleTrack.SingleOrDefault(s => s.StudentID == id && s.TrackNo == 1);
                SaleTrackParticipants = repository.SaleTrackParticipants.Where(s => s.SaleTrackID == SaleTrack.TrackItemID).Select(s => s);
            }
            else
            {
                SaleTrack = new SaleTrackEntity
                {
                    TrackItemID   = Guid.NewGuid(),
                    StudentID     = id,
                    Inputor       = HttpContext.User.Identity.Name,
                    StateName     = "初访",
                    TrackPattern  = TrackPattern.面谈,
                    TrackDate     = studentInfo.CreateTime.AddDays(1),
                    ToDo          = "了解客户需求,完成初访登记表!",
                    IsComplete    = TrackIsComplete.否,
                    SignIntention = appRelation.IsSign,
                    Remark        = ""
                };
                SaleTrackParticipants = Enumerable.Empty <SaleTrackParticipantsEntity>();
            }
            return(Json(new SaleTrackAjaxViewModel {
                SaleTrackItem = SaleTrack,
                SaleTrackParticipant = SaleTrackParticipants
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id">学生ID</param>
        /// <param name="trackID">SaleTrackID</param>
        /// <returns></returns>
        public ViewResult GetFromInterview(Guid id, Guid trackID)
        {
            SaleTrackEntity   saleTrack   = repository.SaleTrack.SingleOrDefault(s => s.TrackItemID == trackID && s.StudentID == id);
            StudentInfoEntity studentInfo = repository.StudentInfo.SingleOrDefault(s => s.StudentID == id);

            ViewBag.StudentInfo = studentInfo;
            return(View(saleTrack));
        }
Ejemplo n.º 4
0
        public JsonResult PostFirstInterviewRegTPForm(FirstInterviewRegModel ajaxData)
        {
            if (ajaxData == null || ajaxData.StudentInfo == null)
            {
                return(Json(false));
            }

            StudentTPInfoEntity studentTPInfo = ajaxData.StudentTPInfo;
            StudentInfoEntity   studentInfo   = repository.StudentInfo.SingleOrDefault(s => s.StudentID == ajaxData.StudentInfo.StudentID);
            AppRelationsEntity  appRelation   = repository.AppRelation.SingleOrDefault(a => a.StudentID == studentInfo.StudentID);

            studentInfo.EducationIntention = ajaxData.StudentInfo.EducationIntention;

            studentInfoRepository.SaveStudentTPInfo(studentTPInfo);
            studentInfoRepository.SaveStudentInfo(studentInfo, appRelation);

            ExamResultEntity        _TFIELTSResult       = ajaxData.TFIELTSResult;
            ExamResultTFIELTSEntity _TFIELTSResultDetail = ajaxData.TFIELTSResultDetail;

            if ((_TFIELTSResult.ExamType == ExamType.TOFEL || _TFIELTSResult.ExamType == ExamType.IELTS))
            {
                repository.SaveExamResult(_TFIELTSResult);
                if (_TFIELTSResultDetail.ExamID != _TFIELTSResult.ExamID)
                {
                    _TFIELTSResultDetail.ExamID = _TFIELTSResult.ExamID = Guid.NewGuid();
                }
                repository.SaveExamResultTFIELTS(_TFIELTSResultDetail);
            }

            EducationIntention eduIntention = studentInfo.EducationIntention;

            switch (eduIntention)
            {
            case EducationIntention.高中:
            {
                ajaxData.SATSSATResult.ExamType = ExamType.SSAT;
                SaveSSATResult(ajaxData.SATSSATResult, ajaxData.SATSSATResultDetail);
                break;
            }

            case EducationIntention.本科:
            {
                ajaxData.SATSSATResult.ExamType = ExamType.SAT;
                repository.SaveExamResult(ajaxData.SAT2Result);
                SaveSATResult(ajaxData.SATSSATResult, ajaxData.SATSSATResultDetail);
                break;
            }

            case EducationIntention.研究生:
                SaveGreGmatResult(ajaxData.GREGMATResult, ajaxData.GREGMATResultDetail);
                break;

            default:
                break;
            }

            return(Json(true));
        }
Ejemplo n.º 5
0
        public async Task <TData <string> > SaveForm(StudentInfoEntity entity)
        {
            TData <string> obj = new TData <string>();
            await studentInfoService.SaveForm(entity);

            obj.Result = entity.Id.ParseToString();
            obj.Tag    = 1;
            return(obj);
        }
Ejemplo n.º 6
0
        public ViewResult Edit(Guid id)
        {
            StudentInfoEntity  studentInfo = repository.StudentsInfo.FirstOrDefault(r => r.StudentID == id);
            AppRelationsEntity appRelation = repository.AppRelations.FirstOrDefault(a => a.StudentID == id);

            return(View(new StudentInfoViewModel {
                StudentInfo = studentInfo, AppRelation = appRelation
            }));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 渲染初访登记表——如何知道APP
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ViewResult FirstRegFormFrom(string id)
        {
            Guid studentID = new Guid(id);
            StudentInfoEntity studentInfo = repository.StudentInfo.SingleOrDefault(s => s.StudentID == studentID);

            ViewBag.StudentInfo = studentInfo;
            IEnumerable <StudentSourceItemEntity> studentSourceItems = repository.StudentSourceItem.Select(s => s);

            return(View(studentSourceItems));
        }
Ejemplo n.º 8
0
        public JsonResult Create(StudentCreateModel ajaxData)
        {
            StudentInfoEntity studentInfo = ajaxData.StudentInfo;

            studentInfo.StudentID = Guid.NewGuid();

            AppRelationsEntity appRelation = ajaxData.AppRelation;

            if (appRelation.IsSign != IsSign.已签约)
            {
                appRelation.SignDate = null;
            }
            appRelation.StudentID = studentInfo.StudentID;
            //appRelation.SaleConsultantName = GetUserName(appRelation.SaleConsultant);

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

            //更新销售顾问的LastJobData
            UserInfoEntity saleUser = repository.UsersInfo.SingleOrDefault(u => u.UserID == appRelation.SaleConsultant);

            saleUser.LastJobDate = DateTime.Now;
            userRepository.SaveUserInfo(saleUser);

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

            if (ajaxData.ContactFather != null)
            {
                AddParentAndChattime(ajaxData.ContactFather, studentInfo.StudentID);
            }
            if (ajaxData.ContactMother != null)
            {
                AddParentAndChattime(ajaxData.ContactMother, studentInfo.StudentID);
            }
            if (ajaxData.ContactOther != null)
            {
                AddParentAndChattime(ajaxData.ContactOther, studentInfo.StudentID);
            }

            return(Json(new { CreateReslut = true, StudentID = studentInfo.StudentID }));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="StudentID"></param>
        /// <returns></returns>
        public ActionResult Delete(Guid StudentID)
        {
            StudentInfoEntity student = repository.StudentsInfo.FirstOrDefault(r => r.StudentID == StudentID);

            if (student != null)
            {
                repository.DeleteStudentInfo(student);
                TempData["message"] = string.Format("{0} was deleted", student.NameCn);
            }
            return(RedirectToAction("List"));
        }
Ejemplo n.º 10
0
        public JsonResult PostFirstInterviewRegInfoForm(FirstInterviewRegModel ajaxData)
        {
            if (ajaxData == null || ajaxData.StudentInfo == null)
            {
                return(Json(false));
            }

            StudentInfoEntity studentInfo = ajaxData.StudentInfo;

            studentInfoRepository.SaveStudentInfo(studentInfo, repository.AppRelation.SingleOrDefault(a => a.StudentID == studentInfo.StudentID));

            return(Json(true));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 根据学生ID返回合适的申请版本
        /// </summary>
        /// <param name="StudentID"></param>
        /// <returns></returns>
        ApplyStageVersionEntity GetApplyVersionByStudentID(Guid StudentID)
        {
            StudentInfoEntity  studentInfo     = repository.StudentsInfo.SingleOrDefault(s => s.StudentID == StudentID);
            AppRelationsEntity appRelation     = repository.AppRelations.SingleOrDefault(s => s.StudentID == StudentID);
            DateTime           studentSignDate = Convert.ToDateTime(appRelation.SignDate);

            //根据月、日进行筛选,并选出符合条件的第一个Entity,通过比较Month与Day两值相加的值来排序比较
            ApplyStageVersionEntity suitableVersion = repository.ApplyStageVersion
                                                      .Where(a => a.SignDateBefore.Month * 100 + a.SignDateBefore.Day >= studentSignDate.Month * 100 + studentSignDate.Day)
                                                      .OrderBy(a => (a.SignDateBefore.Month * 100 + a.SignDateBefore.Day))
                                                      .FirstOrDefault();

            return(suitableVersion);
        }
Ejemplo n.º 12
0
        public async Task DeleteForm(string ids)
        {
            long[] idArr = TextHelper.SplitToArray <long>(ids, ',');
            foreach (var id in idArr)
            {
                StudentInfoEntity entity = new StudentInfoEntity();
                await entity.Modify();

                entity.Id           = id;
                entity.BaseIsDelete = 1;
                await this.BaseRepository().Update <StudentInfoEntity>(entity);
            }
            //await this.BaseRepository().Delete<StudentInfoEntity>(idArr);
        }
Ejemplo n.º 13
0
        public async Task <ActionResult> SaveFormJson(StudentInfoEntity entity)
        {
            if (entity.Id.IsNullOrZero())
            {
                entity.Code = await new StudentInfoCache().GetStudentCode();
            }
            OperatorInfo operatorInfo = await Operator.Instance.Current();

            entity.SysDepartmentId   = operatorInfo.DepartmentId;
            entity.SysDepartmentName = operatorInfo.DepartmentName;
            TData <string> obj = await studentInfoBLL.SaveForm(entity);

            return(Json(obj));
        }
Ejemplo n.º 14
0
        public async Task SaveForm(StudentInfoEntity entity)
        {
            if (entity.Id.IsNullOrZero())
            {
                await entity.Create();

                await this.BaseRepository().Insert(entity);
            }
            else
            {
                await entity.Modify();

                await this.BaseRepository().Update(entity);
            }
        }
Ejemplo n.º 15
0
        public JsonResult AssignConsultant(AssignConsultantData ajaxData)
        {
            if (ajaxData == null || ajaxData.StudentID == null || ajaxData.StudentID == Guid.Empty)
            {
                return(Json(false));
            }

            StudentInfoEntity  studentInfo = repository.StudentsInfo.Single(s => s.StudentID == ajaxData.StudentID);
            AppRelationsEntity relation    = repository.AppRelations.Single(a => a.StudentID == ajaxData.StudentID);

            relation.ApplyConsultant     = ajaxData.ApplyConsultant;
            relation.ApplyConsultantName = ajaxData.ApplyConsultantName;
            relation.EssayConsultant     = ajaxData.EssayConsultant;
            relation.EssayConsultantName = ajaxData.EssayConsultantName;
            relation.ActConsultant       = ajaxData.ActConsultant;
            relation.ActConsultantName   = ajaxData.ActConsultantName;
            relation.ExamConsultant      = ajaxData.ExamConsultant;
            relation.ExamConsultantName  = ajaxData.ExamConsultantName;
            relation.HasAssignConsultant = true;

            repository.SaveStudentInfo(studentInfo, relation);
            List <UserInfoEntity> userList = new List <UserInfoEntity>();

            UserInfoEntity applyConsultant = userRepository.UsersInfo.Single(u => u.UserID == ajaxData.ApplyConsultant);

            applyConsultant.LastJobDate = DateTime.Now;
            userList.Add(applyConsultant);

            UserInfoEntity essayConsultant = userRepository.UsersInfo.Single(u => u.UserID == ajaxData.EssayConsultant);

            essayConsultant.LastJobDate = DateTime.Now;
            userList.Add(essayConsultant);

            UserInfoEntity actConsultant = userRepository.UsersInfo.Single(u => u.UserID == ajaxData.ActConsultant);

            actConsultant.LastJobDate = DateTime.Now;
            userList.Add(actConsultant);

            UserInfoEntity examConsultant = userRepository.UsersInfo.Single(u => u.UserID == ajaxData.ExamConsultant);

            examConsultant.LastJobDate = DateTime.Now;
            userList.Add(examConsultant);

            userRepository.SaveUserList(userList);

            return(Json(true));
        }
Ejemplo n.º 16
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));
        }
Ejemplo n.º 17
0
        public ActionResult Familiar(Guid id)
        {
            AssayMaterialEntity assayMaterialEntity = assayReposity.AssayMaterials.FirstOrDefault(a => a.StudentID == id);

            if (assayMaterialEntity == null)
            {
                assayReposity.SaveAssayMaterial(new AssayMaterialEntity {
                    StudentID = id
                });
                assayMaterialEntity = assayReposity.AssayMaterials.FirstOrDefault(a => a.StudentID == id);
            }
            StudentInfoEntity studentInfo = assayReposity.StudentsInfo.FirstOrDefault(s => s.StudentID == id);

            return(View(new StudentAssayMaterialViewModel {
                AssayMaterial = assayMaterialEntity, StudentInfo = studentInfo
            }));
        }
Ejemplo n.º 18
0
        public void DeleteStudentInfo(StudentInfoEntity studentInfo)
        {
            StudentInfoEntity originStudent = context.StudentsInfo.Where(u => u.StudentID == studentInfo.StudentID).SingleOrDefault();  //根据StudentID查找到就的StudentInfo

            context.StudentsInfo.Remove(originStudent);

            //还有很大段删除操作要进行,因为涉及的数据表很多

            //AppRelation
            AppRelationsEntity appRelation = context.AppRelations.Where(a => a.StudentID == studentInfo.StudentID).SingleOrDefault();

            DeleteAppRelation(appRelation);

            //AssayMaterial
            DeleteAssayMaterial(studentInfo.StudentID);

            context.SaveChanges();
        }
Ejemplo n.º 19
0
        //根据学生ID返回ContactIdentity List
        public JsonResult GetContactIdentityList(string studentID)
        {
            List <ContactIdentity> contacts = new List <ContactIdentity>();
            //每个联系人的联系信息
            ContactIdentity   contactInfo = null;
            StudentInfoEntity studentInfo = null;
            //所有联系人列表,从数据库中读取赋值
            IEnumerable <StudentParentEntity> parents = null;

            if (studentID != null && studentID != string.Empty && studentID != Guid.Empty.ToString())
            {
                Guid id = new Guid(studentID);
                parents     = repository.StudentParent.Where(s => s.StudentID == id);
                studentInfo = repository.StudentsInfo.SingleOrDefault(s => s.StudentID == id);
                contactInfo = new ContactIdentity
                {
                    PersonIdentity = "学生",
                    NameCn         = studentInfo.NameCn,
                    Mobile         = studentInfo.Mobile,
                    Email          = studentInfo.Email
                };
                contacts.Add(contactInfo);
                contactInfo = null;
            }
            if (parents.Count() > 0)
            {
                for (int i = 0; i < parents.Count(); i++)
                {
                    StudentParentEntity parent = parents.ElementAt(i);
                    contactInfo = new ContactIdentity
                    {
                        PersonIdentity = parent.PersonIdentity.ToString(),
                        NameCn         = parent.NameCn,
                        Mobile         = parent.Mobile,
                        Email          = parent.Email
                    };
                    contacts.Add(contactInfo);
                    contactInfo = null;
                }
            }

            return(Json(contacts, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 20
0
        public JsonResult Create(StudentCreateModel ajaxData)
        {
            StudentInfoEntity studentInfo = ajaxData.StudentInfo;

            studentInfo.StudentID = Guid.NewGuid();

            AppRelationsEntity appRelation = ajaxData.AppRelation;

            appRelation.SignDate  = new DateTime(1990, 1, 1);
            appRelation.StudentID = studentInfo.StudentID;

            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 != null)
            {
                foreach (EasyChatTimeEntity item in ajaxData.ContactStudent.EasyChatTimes)
                {
                    item.IfStudentID = studentInfo.StudentID;
                    repository.SaveEasyChatTime(item);      //保存方便联系时间
                }
            }

            if (ajaxData.ContactFather != null)
            {
                AddParentAndChattime(ajaxData.ContactFather, studentInfo.StudentID);
            }
            if (ajaxData.ContactMother != null)
            {
                AddParentAndChattime(ajaxData.ContactMother, studentInfo.StudentID);
            }
            if (ajaxData.ContactOther != null)
            {
                AddParentAndChattime(ajaxData.ContactOther, studentInfo.StudentID);
            }

            return(Json(new { CreateReslut = true, StudentID = studentInfo.StudentID }));
        }
Ejemplo n.º 21
0
        public async Task <ActionResult> GetListJsonCom(StudentInfoListParam param)
        {
            OperatorInfo operatorInfo = await Operator.Instance.Current();

            if (!operatorInfo.RoleIds.Contains(GlobalContext.SystemConfig.RoleId))//不是超级管理员
            {
                param.SysDepartmentId = operatorInfo.DepartmentId;
            }
            TData <List <StudentInfoEntity> > obj = await studentInfoBLL.GetList(param);

            if (obj.Tag == 1 && obj.Result.Count > 0)
            {
                StudentInfoEntity info = new StudentInfoEntity();
                info.Code = "0";
                info.Name = "选择全部学生";
                obj.Result.Insert(0, info);
            }

            return(Json(obj));
        }
Ejemplo n.º 22
0
 public ActionResult Edit(StudentInfoEntity studentInfo, AppRelationsEntity appRelation)
 {
     if (studentInfo.StudentID == Guid.Empty)
     {
         studentInfo.StudentID = Guid.NewGuid();
     }
     appRelation.StudentID = studentInfo.StudentID;
     if (ModelState.IsValid)
     {
         repository.SaveStudentInfo(studentInfo, appRelation);
         TempData["message"] = string.Format("{0} has been saved", studentInfo.NameCn);
         return(RedirectToAction("List"));
     }
     else
     {
         return(View(new StudentInfoViewModel {
             StudentInfo = studentInfo, AppRelation = appRelation
         }));
     }
 }
Ejemplo n.º 23
0
        //根据学生ID返回StudentInfo和AppRelation
        public JsonResult GetStudentInfoViewModel(string studentID)
        {
            StudentInfoEntity  studentInfo = null;
            AppRelationsEntity appRelation = null;

            if (studentID == string.Empty || studentID == Guid.Empty.ToString())
            {
                studentInfo = new StudentInfoEntity();
                appRelation = new AppRelationsEntity {
                    StudentID = studentInfo.StudentID
                };
            }
            else
            {
                Guid id = new Guid(studentID);
                studentInfo = repository.StudentsInfo.SingleOrDefault(s => s.StudentID == id);
                appRelation = repository.AppRelations.SingleOrDefault(a => a.StudentID == id);
            }
            return(Json(new { StudentInfo = studentInfo, AppRelation = appRelation }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 24
0
        public void SaveStudentInfo(StudentInfoEntity studentInfo, AppRelationsEntity appRelation)
        {
            if (studentInfo.StudentID == Guid.Empty)                                                             //如果传入的学生ID为空,则创建一个新的GUID
            {
                studentInfo.StudentID = appRelation.StudentID = Guid.NewGuid();                                  //确保StudentInfo和AppRelation会创建同一个StudentID的对象
            }
            if (context.StudentsInfo.Where(u => u.StudentID == studentInfo.StudentID).SingleOrDefault() == null) //如果数据库不存在传入的Guid,则为添加新记录,否则修改已有对象
            {
                studentInfo.CreateTime = DateTime.Now;
                context.StudentsInfo.Add(studentInfo);
            }
            else
            {
                StudentInfoEntity originStudent = context.StudentsInfo.Where(u => u.StudentID == studentInfo.StudentID).SingleOrDefault();  //根据StudentID查找到就的StudentInfo
                studentInfo.CreateTime = originStudent.CreateTime;
                context.Entry(originStudent).CurrentValues.SetValues(studentInfo);
            }

            SaveAppRelation(appRelation); //同步添加AppRelation

            context.SaveChanges();
        }
Ejemplo n.º 25
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.º 26
0
        /// <summary>
        /// 获取客户的访谈历史
        /// </summary>
        /// <param name="studentID"></param>
        /// <returns></returns>
        public JsonResult GetSaleTrackHistory(string studentID)
        {
            if (studentID == null || studentID == string.Empty)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }

            Guid id = new Guid(studentID);

            List <SaleTrackAjaxViewModel> historyList = new List <SaleTrackAjaxViewModel>();

            IEnumerable <SaleTrackParticipantsEntity>[] participantsArray = null;
            IEnumerable <SaleTrackEntity> saleTrackEntityHistory          = repository.SaleTrack.Where(s => s.StudentID == id).OrderBy(s => s.TrackNo);

            if (saleTrackEntityHistory.Count() > 0)
            {
                participantsArray = new IEnumerable <SaleTrackParticipantsEntity> [saleTrackEntityHistory.Count()];
                for (int i = 0; i < saleTrackEntityHistory.Count(); i++)
                {
                    SaleTrackEntity item = saleTrackEntityHistory.ElementAt(i);
                    participantsArray[i] = repository.SaleTrackParticipants.Where(s => s.SaleTrackID == item.TrackItemID);
                    historyList.Add(new SaleTrackAjaxViewModel {
                        SaleTrackItem = item, SaleTrackParticipant = participantsArray[i]
                    });
                }
            }

            //以下写法会造成SaleTrackHistory中出现一样的ParticipantList
            //foreach (SaleTrackEntity item in repository.SaleTrack.Where(s=>s.StudentID == id).OrderBy(s=>s.TrackNo))
            //{
            //    IEnumerable<SaleTrackParticipantsEntity> participants = repository.SaleTrackParticipants.Where(s => s.SaleTrackID == item.TrackItemID);
            //    historyList.Add(new SaleTrackAjaxViewModel { SaleTrackItem = item, SaleTrackParticipant = participants });
            //    participants = null;
            //}

            StudentInfoEntity studentInfo = repository.StudentInfo.SingleOrDefault(s => s.StudentID == id);

            return(Json(new { StudentInfo = studentInfo, SaleTrackHistory = historyList }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 根据学生ID获取初访数据
        /// </summary>
        /// <param name="studentID">学生ID</param>
        /// <returns></returns>
        public JsonResult GetFirstInterviewRegData(string studentID)
        {
            if (studentID == null || studentID == string.Empty)
            {
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            Guid id = new Guid(studentID);
            StudentInfoEntity      studentInfo  = repository.StudentInfo.SingleOrDefault(s => s.StudentID == id);
            AppRelationsEntity     appRelation  = repository.AppRelation.SingleOrDefault(a => a.StudentID == id);
            StudentTPInfoEntity    studentTP    = GetStudentTP(id);
            ExamResultTFIELTSModel tfIELTSModel = GetTFIELTSExamResult(id);
            ExamResultSATSSATModel satSSATModel = GetSATSSATExamResult(id);
            ExamResultEntity       sat2Model    = GetSAT2ExamResult(id);
            ExamResultGREGMATModel greGmatModel = GetGREGMATExamResult(id);
            ExamResultEntity       apModel      = GetAPResult(id);
            IEnumerable <StudentSourceItemEntity> studentSourceList     = GetStudentSourceList();
            IEnumerable <StudentFromEntity>       studentFromList       = GetStudentFromList(id);
            IEnumerable <StudentFlashPointEntity> studentFlashPointList = GetFlashPointList(id);

            FirstInterviewRegModel firstInterviewRegMode = new FirstInterviewRegModel
            {
                StudentInfo           = studentInfo,
                AppRelation           = appRelation,
                StudentTPInfo         = studentTP,
                TFIELTSResult         = tfIELTSModel.ExamResult,
                TFIELTSResultDetail   = tfIELTSModel.ExamResultDetail,
                SATSSATResult         = satSSATModel.ExamResult,
                SATSSATResultDetail   = satSSATModel.ExamResultDetail,
                SAT2Result            = sat2Model,
                GREGMATResult         = greGmatModel.ExamResult,
                GREGMATResultDetail   = greGmatModel.ExamResultDetail,
                APResult              = apModel,
                StudentSourceList     = studentSourceList,
                StudentFromList       = studentFromList,
                StudentFlashPointList = studentFlashPointList
            };

            return(Json(firstInterviewRegMode, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 28
0
        public JsonResult EditStudent(StudentInfoEntity studentInfo, AppRelationsEntity appRelation, IEnumerable <EasyChatTimeEntity> EasyChatTimes)
        {
            bool editResult = true;

            if (studentInfo != null && appRelation != null)
            {
                //获取学生现在的销售顾问的ID,等下将要与新的销售顾问进行比较
                Guid?currentSaleConsultantID = repository.AppRelations.Single(a => a.StudentID == studentInfo.StudentID).SaleConsultant;

                //保存StudentInfo、AppRelation 信息到数据库中
                repository.SaveStudentInfo(studentInfo, appRelation);

                //只有在销售顾问有变化时才更新新销售顾问的LastJobData
                if (currentSaleConsultantID != appRelation.SaleConsultant)
                {
                    UserInfoEntity saleUser = repository.UsersInfo.SingleOrDefault(u => u.UserID == appRelation.SaleConsultant);
                    saleUser.LastJobDate = DateTime.Now;
                    userRepository.SaveUserInfo(saleUser);
                }

                //删除EasyChatTimes中与学生有关的所有记录
                repository.EmptyStudentEasyChatTimes(studentInfo.StudentID);

                //遍历EasyChatTimes, 并添加到数据库中
                if (EasyChatTimes != null)
                {
                    foreach (EasyChatTimeEntity item in EasyChatTimes)
                    {
                        repository.SaveEasyChatTime(item);
                    }
                }
            }
            else
            {
                editResult = false;
            }
            return(Json(new { EditResult = editResult }));
        }
Ejemplo n.º 29
0
        public ViewResult CommonInterview(Guid id, int TrackNo)
        {
            StudentInfoEntity studentInfo = repository.StudentInfo.FirstOrDefault(s => s.StudentID == id);
            SaleTrackEntity   SaleTrack;
            IEnumerable <SaleTrackParticipantsEntity> SaleTrackParticipants = null;

            if (repository.SaleTrack.SingleOrDefault(s => s.StudentID == id && s.TrackNo == TrackNo) != null)
            {
                SaleTrack             = repository.SaleTrack.SingleOrDefault(s => s.StudentID == id && s.TrackNo == TrackNo);
                SaleTrackParticipants = repository.SaleTrackParticipants.Where(s => s.SaleTrackID == SaleTrack.TrackItemID).Select(s => s);
            }
            else
            {
                DateTime nextDate = repository.SaleTrack.SingleOrDefault(s => s.StudentID == id && s.TrackNo == TrackNo - 1).TrackDate;
                SaleTrack = new SaleTrackEntity
                {
                    TrackItemID  = Guid.NewGuid(),
                    StudentID    = id,
                    Inputor      = "Admin",
                    StateName    = "第" + TrackNo.ToString() + "次回访",
                    TrackNo      = (byte)TrackNo,
                    TrackPattern = TrackPattern.面谈,
                    TrackDate    = nextDate.AddDays(1),
                    ToDo         = "第" + TrackNo.ToString() + "次回访",
                    IsComplete   = TrackIsComplete.否,
                    Remark       = "请输入备注信息 "
                };
                SaleTrackParticipants = Enumerable.Empty <SaleTrackParticipantsEntity>();
            }
            return(View(new SaleTrackViewModel
            {
                StudentInfo = studentInfo,
                SaleTrack = SaleTrack,
                SaleTrackParticipants = SaleTrackParticipants,
                AdditionalIdentity = SaleParticipantIdentity.咨询顾问
            }));
        }
Ejemplo n.º 30
0
        public void SaveStudentFrom(IEnumerable <StudentFromEntity> studentFroms, Guid studentID)
        {
            StudentInfoEntity studentInfo = context.StudentsInfo.FirstOrDefault(s => s.StudentID == studentID);

            if (studentInfo == null)
            {
                throw new Exception("当前学生信息不存在");
            }
            if (studentFroms == null || studentFroms.Count() == 0)
            {
                context.StudentFrom.RemoveRange(context.StudentFrom.Where(s => s.StudentID == studentInfo.StudentID).Select(s => s));
            }
            else
            {
                context.StudentFrom.RemoveRange(context.StudentFrom.Where(s => s.StudentID == studentInfo.StudentID).Select(s => s));
                foreach (StudentFromEntity fromItem in studentFroms)
                {
                    fromItem.ID = Guid.NewGuid();       //重置ID
                    context.StudentFrom.Add(fromItem);
                }
            }

            context.SaveChanges();
        }