예제 #1
0
        public async Task EditStudent(EditStudentInput input)
        {
            var student = await _studentRepository.GetAsync(input.Id);

            student.Name         = input.Name;
            student.Surname      = input.Surname;
            student.EmailAddress = input.EmailAddress;
            await _studentRepository.UpdateAsync(student);
        }
예제 #2
0
        public async Task CreatStudentInfo(EditStudentInput input)
        {
            var student = await _studentRepository.FirstOrDefaultAsync(x => x.Id == input.Id);

            if (student == null)
            {
                throw new UserFriendlyException($"登陆账号{input.LoginId}不存在!");
            }
            if (student.UserName != input.LoginId)
            {
                var existsUser = await _userRepository.FirstOrDefaultAsync(x => x.UserName == input.LoginId);

                if (existsUser != null)
                {
                    throw new UserFriendlyException($"登陆账号{input.LoginId}已存在!");
                }
            }
            //TenantId = AbpSession.TenantId,
            //    Password = new PasswordHasher().HashPassword(Teacher.DefaultTeacherPassword),
            //    UserName = "******",
            //    Name = "mingzi",
            //    Surname = "StudentName",
            //    EmailAddress = "*****@*****.**",



            #region 根据学号处理入学时间年级
            if (input.LoginId.Length < 4)
            {
                throw new UserFriendlyException("学号格式不正确");
            }
            var yearstr = input.LoginId.Substring(0, 4);
            int year;
            try
            {
                year = Convert.ToInt32(yearstr);
            }
            catch (Exception)
            {
                throw new UserFriendlyException("学号格式不正确");
            }
            var    entryDate = new DateTime(year, 8, 20);
            var    grade     = Math.Min(((DateTime.Today.Year - entryDate.Year) * 12 + (DateTime.Today.Month - entryDate.Month)) / 12, 4);
            string gradestr;
            switch (grade)
            {
            case 0:
                gradestr = "一年级";
                break;

            case 1:
                gradestr = "二年级";
                break;

            case 2:
                gradestr = "三年级";
                break;

            case 3:
                gradestr = "四年级";
                break;

            case 4:
                gradestr = "五年级";
                break;

            default:
                gradestr = "五年级";
                break;
            }
            #endregion

            //student.StudentNo = input.StudentNo;    //2
            student.StudentNo = input.LoginId;
            //student.EntryDate = input.EntryDate;
            student.Gender          = input.Gender;
            student.Tel             = input.Tel;
            student.Major           = input.Major;
            student.Grade           = gradestr;
            student.Class           = input.Class;
            student.OriginOfStudent = input.OriginOfStudent;
            student.Department      = input.Department;
            student.ProfessionLevel = input.ProfessionLevel;

            student.EntryDate = entryDate;                //4

            student.IsEmailConfirmed = true;

            student = await _studentRepository.UpdateAsync(student);
        }
예제 #3
0
        public async Task EditStudent(EditStudentInput input)
        {
            var student = _studentRepository.FirstOrDefault(x => x.Id == input.Id);

            if (student == null)
            {
                throw new UserFriendlyException($"学号{input.LoginId}不存在!");
            }

            if (input.LoginId.ToString() != student.UserName)
            {
                var existsStudent = _studentRepository.FirstOrDefault(x => x.UserName == input.LoginId.ToString());
                if (existsStudent != null)
                {
                    throw new UserFriendlyException($"学号{input.LoginId}已存在!");
                }
            }


            #region 根据学号处理入学时间年级
            if (input.LoginId.Length < 4)
            {
                throw new UserFriendlyException("学号格式不正确");
            }
            var yearstr = input.LoginId.Substring(0, 4);
            int year;
            try
            {
                year = Convert.ToInt32(yearstr);
            }
            catch (Exception)
            {
                throw new UserFriendlyException("学号格式不正确");
            }
            var    entryDate = new DateTime(year, 8, 20);
            var    grade     = Math.Min(((DateTime.Today.Year - entryDate.Year) * 12 + (DateTime.Today.Month - entryDate.Month)) / 12, 4);
            string gradestr;
            switch (grade)
            {
            case 0:
                gradestr = "一年级";
                break;

            case 1:
                gradestr = "二年级";
                break;

            case 2:
                gradestr = "三年级";
                break;

            case 3:
                gradestr = "四年级";
                break;

            case 4:
                gradestr = "五年级";
                break;

            default:
                gradestr = "五年级";
                break;
            }
            #endregion

            student.Name    = input.StudentName;
            student.Surname = input.StudentName;
            //student.UserName = input.StudentNo;              //2
            student.UserName = input.LoginId;
            student.Grade    = gradestr;

            student.Department = input.Department;
            student.Major      = input.Major;
            student.Gender     = input.Gender;
            student.EntryDate  = entryDate;           //4
            // student.StudentNo = input.StudentNo;        //2

            await _studentRepository.UpdateAsync(student);
        }