コード例 #1
0
        public async Task <IOutput> Handle(CreateTeacherInput request, CancellationToken cancellationToken)
        {
            var teacher = new Entities.Teacher
            {
                Name = request.Name
            };

            _context.Teachers.Add(teacher);

            await _context.SaveChangesAsync(cancellationToken);

            return(ObjectOutput.CreateWithId(teacher.Id));
        }
コード例 #2
0
        /// <summary>
        /// 验证账号是否已经存在
        /// </summary>
        /// <param name="source"></param>
        /// <param name="args"></param>
        protected void cusv_ServerValidate(object source, ServerValidateEventArgs args)
        {
            Song.Entities.Organization org = Business.Do <IOrganization>().OrganCurrent();
            Song.Entities.Teacher      th  = Business.Do <ITeacher>().TeacherSingle(id);
            if (th == null)
            {
                th = new Entities.Teacher();
            }
            th.Org_ID = org.Org_ID;
            //判断是否通过验证
            bool isAccess = Business.Do <ITeacher>().IsTeacherExist(org.Org_ID, th);

            args.IsValid = !isAccess;
        }
コード例 #3
0
        public bool Ekle(Entities.Teacher model)
        {
            var result = false;

            try
            {
                this.dbContext.Teachers.Add(model);
                this.dbContext.SaveChanges();
                result = true;
            }
            catch (Exception)
            {
            }
            return(result);
        }
コード例 #4
0
        public bool Güncelle(int index, Entities.Teacher model)
        {
            var result = false;

            try
            {
                var data = this.dbContext.Teachers.Where(x => x.id == index).First();
                data.lesson_id = model.lesson_id;
                this.dbContext.SaveChanges();
                result = true;
            }
            catch (Exception)
            {
            }
            return(result);
        }
コード例 #5
0
 public void Delete(Entities.Teacher entity)
 {
     _teacherDAL.Remove(entity);
 }
コード例 #6
0
 public void Update(Entities.Teacher entity)
 {
     _teacherDAL.Update(entity);
 }
コード例 #7
0
 public void Insert(Entities.Teacher entity)
 {
     _teacherDAL.Add(entity);
 }
コード例 #8
0
        /// <summary>
        /// 教师注册的验证
        /// </summary>
        private void mobiregister_verify()
        {
            string vname    = WeiSha.Common.Request.Form["vname"].String;
            string imgCode  = WeiSha.Common.Request.Cookies[vname].ParaValue; //取图片验证码
            string userCode = WeiSha.Common.Request.Form["vcode"].MD5;        //取输入的验证码
            string phone    = WeiSha.Common.Request.Form["phone"].String;     //输入的手机号
            string sms      = WeiSha.Common.Request.Form["sms"].MD5;          //输入的短信验证码
            string name     = WeiSha.Common.Request.Form["name"].String;      //姓名
            string email    = WeiSha.Common.Request.Form["email"].String;     //邮箱
            string qq       = WeiSha.Common.Request.Form["qq"].String;        //qq
            string idcard   = WeiSha.Common.Request.Form["idcard"].String;    //身份证号
            string intro    = WeiSha.Common.Request.Form["intro"].Text;       //简介

            //验证图片验证码
            if (imgCode != userCode)
            {
                Response.Write("{\"success\":\"-1\",\"state\":\"1\"}");   //图片验证码不正确
                return;
            }
            //验证手机号是否存在
            Song.Entities.Accounts curr = Extend.LoginState.Accounts.CurrentUser;
            if (curr == null)
            {
                Response.Write("{\"success\":\"-1\",\"state\":\"4\"}");   //当前账号未登录;
                return;
            }
            if (phone != curr.Ac_MobiTel1 && phone != curr.Ac_MobiTel2)
            {
                Song.Entities.Accounts acc = Business.Do <IAccounts>().IsAccountsExist(-1, phone, 1);
                if (acc != null)
                {
                    Response.Write("{\"success\":\"-1\",\"state\":\"2\"}");   //手机号已经存在
                    return;
                }
            }
            //验证短信验证码
            bool   isSmsCode = true;    //是否短信验证;
            string smsCode   = WeiSha.Common.Request.Cookies["reg_mobi_" + vname].ParaValue;

            if (isSmsCode && sms != smsCode)
            {
                Response.Write("{\"success\":\"-1\",\"state\":\"3\"}");  //短信验证失败
                return;
            }
            else
            {
                Song.Entities.Accounts tmp = Extend.LoginState.Accounts.CurrentUser;
                tmp.Ac_IsTeacher = true;    //当前账户有了教师身份
                tmp.Ac_MobiTel2  = phone;
                Business.Do <IAccounts>().AccountsSave(tmp);
                //创建教师账户
                Song.Entities.Teacher th = Business.Do <IAccounts>().GetTeacher(curr.Ac_ID, null);
                if (th == null)
                {
                    th = new Entities.Teacher();
                }
                th.Ac_ID           = tmp.Ac_ID; //关联学员账户
                th.Ac_UID          = tmp.Ac_UID;
                th.Th_PhoneMobi    = phone;     //教师手机号,基本账号中已经有记录,此处再记一次
                th.Th_Name         = name;      //教师的名称
                th.Th_IDCardNumber = idcard;    //教师的身份证号
                th.Th_Email        = email;
                th.Th_Qq           = qq;
                th.Th_Intro        = intro; //教师的简介

                //如果需要审核通过
                WeiSha.Common.CustomConfig config = CustomConfig.Load(this.Organ.Org_Config);
                th.Th_IsPass = !(bool)(config["IsVerifyTeahcer"].Value.Boolean ?? true);
                th.Th_IsUse  = th.Th_IsPass;
                if (th.Th_ID < 1)
                {
                    int id = Business.Do <ITeacher>().TeacherAdd(th);
                }
                else
                {
                    Business.Do <ITeacher>().TeacherSave(th);
                }

                //注册成功,以下为判断是否审核通过
                if (th.Th_IsPass)
                {
                    LoginState.Accounts.Write(tmp);
                    Response.Write("{\"success\":\"1\",\"name\":\"" + th.Th_Name + "\",\"state\":\"1\"}");
                }
                else
                {
                    //注册成功,但待审核
                    Response.Write("{\"success\":\"1\",\"name\":\"" + th.Th_Name + "\",\"state\":\"0\"}");
                }
            }
        }
コード例 #9
0
        public async Task <TeacherDto> GetByIdAsync(int id)
        {
            Entities.Teacher brand = await _context.Teachers.FindAsync(id);

            return(_mapper.Map <Entities.Teacher, TeacherDto>(brand));
        }
コード例 #10
0
        /// <summary>
        /// 将某一行数据加入到数据库
        /// </summary>
        /// <param name="dr"></param>
        /// <param name="dl"></param>
        private void _inputData(DataRow dr)
        {
            //取所有分类
            if (org == null)
            {
                org = Business.Do <IOrganization>().OrganCurrent();
            }
            if (this.sorts == null)
            {
                this.sorts = Business.Do <ITeacher>().SortCount(org.Org_ID, null, 0);
            }
            Song.Entities.Accounts acc     = null;
            Song.Entities.Teacher  teacher = null;
            bool isExistAcc = false;  //是否存在该账号
            bool isExistTh  = false;  //是否存在该教师

            foreach (KeyValuePair <String, String> rel in ExcelInput1.DataRelation)
            {
                //Excel的列的值
                string column = dr[rel.Key].ToString();
                //数据库字段的名称
                string field = rel.Value;
                if (field == "Th_PhoneMobi")
                {
                    acc = Business.Do <IAccounts>().AccountsSingle(column, -1);
                    if (acc != null)
                    {
                        teacher = Business.Do <IAccounts>().GetTeacher(acc.Ac_ID, null);
                    }
                    isExistAcc = acc != null;
                    isExistTh  = teacher != null;
                    continue;
                }
            }
            if (acc == null)
            {
                acc = new Entities.Accounts();
            }
            if (teacher == null)
            {
                teacher = new Entities.Teacher();
            }
            foreach (KeyValuePair <String, String> rel in ExcelInput1.DataRelation)
            {
                //Excel的列的值
                string column = dr[rel.Key].ToString();
                //数据库字段的名称
                string field = rel.Value;
                if (field == "Th_Sex")
                {
                    teacher.Th_Sex = (short)(column == "男" ? 1 : 2);
                    continue;
                }
                PropertyInfo[] properties = teacher.GetType().GetProperties();
                for (int j = 0; j < properties.Length; j++)
                {
                    PropertyInfo pi = properties[j];
                    if (field == pi.Name && !string.IsNullOrEmpty(column))
                    {
                        pi.SetValue(teacher, Convert.ChangeType(column, pi.PropertyType), null);
                    }
                }
            }
            //设置分组
            if (!string.IsNullOrWhiteSpace(teacher.Ths_Name))
            {
                teacher.Ths_ID = _getDepartId(sorts, teacher.Ths_Name);
            }
            if (!string.IsNullOrWhiteSpace(teacher.Th_Pw))
            {
                teacher.Th_Pw = teacher.Th_Pw.Trim();
            }
            acc.Org_ID         = teacher.Org_ID = org.Org_ID;
            acc.Ac_Name        = teacher.Th_Name;
            teacher.Org_Name   = org.Org_Name;
            teacher.Th_AccName = teacher.Th_PhoneMobi;
            acc.Ac_IsPass      = teacher.Th_IsPass = true;
            teacher.Th_IsShow  = true;
            acc.Ac_IsUse       = teacher.Th_IsUse = true;
            //如果账号不存在
            if (!isExistAcc)
            {
                acc.Ac_AccName      = acc.Ac_MobiTel1 = acc.Ac_MobiTel2 = teacher.Th_PhoneMobi;            //账号手机号
                acc.Ac_Pw           = new WeiSha.Common.Param.Method.ConvertToAnyValue(teacher.Th_Pw).MD5; //密码
                acc.Ac_Sex          = teacher.Th_Sex;                                                      //性别
                acc.Ac_Birthday     = teacher.Th_Birthday;
                acc.Ac_Qq           = teacher.Th_Qq;
                acc.Ac_Email        = teacher.Th_Email;
                acc.Ac_IDCardNumber = teacher.Th_IDCardNumber; //身份证
                acc.Ac_IsTeacher    = true;                    //该账号有教师身份
                //保存
                teacher.Ac_ID = Business.Do <IAccounts>().AccountsAdd(acc);
                Business.Do <ITeacher>().TeacherSave(teacher);
            }
            else
            {
                acc.Ac_IsTeacher = true;
                teacher.Ac_ID    = acc.Ac_ID;
                //如果账号存在,但教师不存在
                if (!isExistTh)
                {
                    Business.Do <ITeacher>().TeacherAdd(teacher);
                }
                else
                {
                    teacher.Th_Pw = new WeiSha.Common.Param.Method.ConvertToAnyValue(teacher.Th_Pw).MD5;    //密码
                    Business.Do <ITeacher>().TeacherSave(teacher);
                }
            }
        }