Esempio n. 1
0
 public JsonResult UpdateStudentInfoById(string userId, int studentId, string updateObj)
 {
     var model = StudentBLL.GetStudentById(studentId);
     var Msg = string.Empty;
     var restult = false;
     var uid = CommonHelper.To<int>(userId.Split(',')[0]);
     var count = userId.Trim(',').Split(',').Count();
     if (count >= 2)
     {
         Msg = "只能选择一个SA或者CC哦!";
     }
     else
     {
         if (updateObj == "SA")
         {
             model.SA = uid;
             model.UpdateTime = DateTime.Now;
             model.UpdateBy = LoginUserManager.CurrLoginUser.UserId;
         }
         else
         {
             model.CC = uid;
             model.UpdateTime = DateTime.Now;
             model.UpdateBy = LoginUserManager.CurrLoginUser.UserId;
         }
         restult = StudentBLL.UpdateStudent(model);
         //同步SA至CRM
         if (restult && updateObj == "SA")
         {
             var crmContractIds = StudentBLL.GetCrmContractIdByStudentId(studentId);
             var user = UserBLL.GetUserById(uid);
             var username = string.Empty;
             if (null != user)
             {
                 username = user.UserName;
             }
             foreach (var crmContractId in crmContractIds)
             {
                 if (crmContractId.HasValue)
                 {
                     ICrmSyncSaAPI syscSA = new CrmSyncSaAPI();
                     var retTip = syscSA.SyncSa(crmContractId.Value, username);
                 }
             }
         }
     }
     return Json(new { status = restult, msg = Msg }, JsonRequestBehavior.DenyGet);
 }
Esempio n. 2
0
        public JsonResult CreateBookRecord(int studentId, int productLevelId, int contractLevelId, int arrangeCourseId, bool isForce = false)
        {
            // var tip = StudyBLL.CreateStudentBookRecord(studentId, contractLevelId, productLevelId, arrangeCourseId, LoginUserManager.CurrLoginUser.UserId, isForce: isForce);
            string postUrl = string.Concat(Global.EmeApiUrl, "/MiniEmeApi", "/BusiEMEBookCourseByUserId");
            var jsonParam = JsonHelper.ToJson(new BookCourseParamModel()
            {
                StudentId = studentId,
                BookSource = ConvertEnum.BookSourceForEmeSelf,
                ArrangeCourseId = arrangeCourseId,
                IsForce = isForce,
                BookUserId = LoginUserManager.CurrLoginUser.UserId,
                ProductLevelId = productLevelId,
                ContractLevelId = contractLevelId
            });
            string result = HttpHelper.OpenRead(postUrl, jsonParam);
            var resultData = JsonHelper.FromJson<ResultTiper>(result);

            var arrangeCourse = StudyBLL.GetArrangeCourseById(arrangeCourseId);
            if (resultData.Status == 100 && arrangeCourse.IsOc)
            {
                var teacher = arrangeCourse.TeachRecord.FirstOrDefault(t => t.Status == ConvertEnum.StatusTypeForActive);
                var stu = StudentBLL.GetStudentById(studentId);
                if (null != teacher && !stu.SA.HasValue)
                {
                    //同步SA至CRM
                    var crmContractIds = StudentBLL.GetCrmContractIdByStudentId(studentId);
                    var user = UserBLL.GetUserById(teacher.Teacher.UserId);
                    var username = string.Empty;
                    if (null != user)
                    {
                        username = user.UserName;
                    }
                    foreach (var crmContractId in crmContractIds)
                    {
                        if (crmContractId.HasValue)
                        {
                            ICrmSyncSaAPI syscSA = new CrmSyncSaAPI();
                            var retTip = syscSA.SyncSa(crmContractId.Value, username);
                        }
                    }
                }
            }
            return Json(new
            {
                status = result,
                msg = resultData.Msg
            }, JsonRequestBehavior.DenyGet);
        }