예제 #1
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="register"></param>
        public int Register(DtoStudentRegister register)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    int studentId = AddStudent(register.Name, register.Grade, register.Phone, register.Source, register.OperatorId);

                    AddStudentPassport(studentId, register.PassportType, register.Phone, register.Password);

                    int studentLoginId = AddStudentLogin(studentId);

                    AddSumStudent(studentLoginId);

                    //查询学生可领取的注册券
                    CashVoucherBll cashVoucherBll     = new CashVoucherBll();
                    var            studentCashVoucher = cashVoucherBll.GetAvailableRegisterVoucher(studentId);
                    //领取注册券
                    foreach (var item in studentCashVoucher)
                    {
                        var studentCashVoucher1 = cashVoucherBll.TakeStudentCashVoucher(studentId, item.Ycv_Id, VoucherGotTypeEnum.注册领取, 0);
                    }
                    if (studentCashVoucher != null && studentCashVoucher.Count > 0)
                    {
                        WebHelper.WriteCookie("CashVoucher", "CashVoucher");
                    }

                    scope.Complete();

                    return(studentId);
                }
                catch (Exception ex)
                {
                    RollbackTran();
                    throw ex;
                }
            }
        }
예제 #2
0
        public ActionResult RegistStudent(string phone, string pwd, string name, int grade, string code)
        {
            bool   success   = false;
            int    studentId = 0;
            string msg       = "";
            bool   checkCode = true;
            var    student   = studentInfoBll.GetStudentInfoByAccount(phone);

            if (student != null)
            {
                msg = "该手机号已注册";
            }
            else
            {
                try
                {
                    checkCode = SmsCookie.GetSmsCode.Check(phone, code);
                }
                catch (Exception)
                {
                    checkCode = false;
                }
                if (checkCode)
                {
                    DtoStudentRegister model = new DtoStudentRegister();
                    model.Phone        = phone;
                    model.Grade        = grade;
                    model.Name         = name;
                    model.OperatorId   = CurrentUser.Teacher.Yoh_Id;
                    model.PassportType = Domain.Enum.StudentAccountSourceEnum.手机;
                    model.Password     = Encrypt.GetMD5Pwd(pwd);
                    model.Phone        = phone;
                    model.SmsCode      = code;
                    model.SchoolId     = 0;
                    model.Source       = Domain.Enum.RegisterRegSourceEnum.校区注册;

                    studentId = studentInfoBll.Register(model);
                    if (studentId > 0)
                    {
                        success = studentApplyBll.StudentApply(studentId, CurrentUser.Teacher.Yoh_Phone, CurrentUser.Teacher.Yoh_Id);
                        msg     = success ? "注册成功" : "注册成功,添加失败";
                    }
                    else
                    {
                        success = false;
                        msg     = "注册失败";
                    }
                    success = true;
                }
                else
                {
                    success = false;
                    msg     = "验证码错误";
                }
            }


            return(Json(new JsonSimpleResponse()
            {
                State = success, ErrorMsg = msg
            }));
        }
예제 #3
0
        public ActionResult Register(RegisterInputModel inputModel)
        {
            if (string.IsNullOrEmpty(inputModel.Phone.Trim()))
            {
                return(Json(new JsonSimpleResponse()
                {
                    ErrorCode = -5, ErrorMsg = "请输入手机号"
                }));
            }
            if (string.IsNullOrEmpty(inputModel.SmsCode.Trim()))
            {
                return(Json(new JsonSimpleResponse()
                {
                    ErrorCode = -6, ErrorMsg = "请输入手机验证码"
                }));
            }
            if (string.IsNullOrEmpty(inputModel.Name.Trim()))
            {
                return(Json(new JsonSimpleResponse()
                {
                    ErrorCode = -7, ErrorMsg = "请输入姓名"
                }));
            }
            if (inputModel.Grade <= 0)
            {
                return(Json(new JsonSimpleResponse()
                {
                    ErrorCode = -8, ErrorMsg = "请选择年级"
                }));
            }

            if (SmsCookie.GetSmsCode == null || !SmsCookie.GetSmsCode.Check(inputModel.Phone, inputModel.SmsCode))
            {
                return(new JsonResult()
                {
                    Data = AjaxResponse.Fail(SmsErrorEnum.PhoneCodeFault)
                });
            }

            StudentInfoBll studentInfoBll = new StudentInfoBll();
            var            isExist        = studentInfoBll.IsExistPhone(inputModel.Phone);

            if (isExist)
            {
                return(Json(new JsonSimpleResponse()
                {
                    ErrorCode = -9, ErrorMsg = "手机号已存在"
                }));
            }
            inputModel.Password = Encrypt.GetMD5Pwd(inputModel.Password);
            DtoStudentRegister register = inputModel.ConvertTo <DtoStudentRegister>();
            int studentId = studentInfoBll.Register(register);

            if (studentId > 0)
            {
                DtoSumStudentTip sumStudent = studentInfoBll.GetSumStudentTip(studentId);
                LoginInfo        info       = sumStudent.ConvertTo <LoginInfo>();
                LoginStudent.Info = JsonConvert.SerializeObject(info);
                return(Json(new JsonSimpleResponse()
                {
                    State = true, ErrorMsg = "注册成功", ErrorCode = 1
                }));
            }
            return(Json(new JsonSimpleResponse()
            {
                State = false, ErrorMsg = "注册失败", ErrorCode = -1
            }));
        }