Exemple #1
0
        public bool InsertStudentMeta(StudentMetaQO newStudentMetaQO)
        {
            var studentMeta = _context.StudentMeta.Find(newStudentMetaQO.Number);

            if (studentMeta != null)
            {
                return(false);                    //如果已经存在该学号就添加失败
            }
            var newStudentMeta = new StudentMeta
            {
                Number = newStudentMetaQO.Number,
                Name   = newStudentMetaQO.Name,
                Major  = newStudentMetaQO.Major,
                Grade  = newStudentMetaQO.Grade,
                Status = newStudentMetaQO.Status
            };

            _context.StudentMeta.Add(newStudentMeta);
            _context.SaveChanges();
            return(true);
        }
Exemple #2
0
        public async Task <IActionResult> UpdateAsync(string id, string idStudent, StudentMeta nameStudent)
        {
            var result = await _studentService.UpdateAsync(id, idStudent, nameStudent);

            return(Ok(result));
        }
Exemple #3
0
        public async Task <ActionResultReponese <string> > UpdateAsync(string id, string idstudent, StudentMeta studenMeta)
        {
            var isNameExit = await _studentRepository.CheckExistsAsync(id);

            if (!isNameExit)
            {
                return(new ActionResultReponese <string>(-4, "Student khong ton tai", "Student"));
            }
            var isIdclass = await _iclassRepository.CheckIdAsync(studenMeta.IdClass);

            if (!isIdclass)
            {
                return(new ActionResultReponese <string>(-3, "Class khong ton tai", "ClassPecialized"));
            }

            var info = await _studentRepository.GetInfoAsync(id);

            if (info == null)
            {
                return(new ActionResultReponese <string>(-1, "Student khong tim thay", "Student"));
            }

            info.id          = id.ToString();
            info.idStudent   = idstudent?.Trim();
            info.LastName    = studenMeta.LastName?.Trim();
            info.Name        = studenMeta.Name?.Trim();
            info.Email       = studenMeta.Email?.Trim();
            info.IdClass     = studenMeta.IdClass?.Trim();
            info.PhoneNumber = studenMeta.PhoneNumber?.Trim();

            var result = await _studentRepository.UpdateAsync(info);

            if (result >= 0)
            {
                return(new ActionResultReponese <string>(result, "Update Student thanh cong", "Student"));
            }
            return(new ActionResultReponese <string>(result, "Update Student khong thanh cong", "strudent"));
        }
Exemple #4
0
        public async Task <ActionResultReponese <string> > InsertAsync(string idStudent, StudentMeta studentMeta)
        {
            var _idstudent = Guid.NewGuid().ToString();

            var isIdClass = await _iclassRepository.CheckIdAsync(studentMeta.IdClass);

            if (!isIdClass)
            {
                return(new ActionResultReponese <string>(-5, "IdClass khong ton tai", "ClassSpecializd"));
            }

            var isIdStudent = await _studentRepository.CheckIstudentAsync(idStudent);

            if (isIdClass)
            {
                return(new ActionResultReponese <string>(-7, "Student da ton tai", "Student"));
            }

            var _student = new Students
            {
                id          = _idstudent,
                idStudent   = idStudent?.Trim(),
                LastName    = studentMeta.LastName?.Trim(),
                Name        = studentMeta.Name?.Trim(),
                Email       = studentMeta.Email?.Trim(),
                IdClass     = studentMeta.IdClass?.Trim(),
                PhoneNumber = studentMeta.PhoneNumber?.Trim(),
                CreateDate  = DateTime.Now,
                IsActive    = true,
                IsDelete    = false,
            };
            var result = await _studentRepository.InsertAsync(_student);

            if (result >= 0)
            {
                return(new ActionResultReponese <string>(result, "Insert thanh cong", "Students"));
            }
            return(new ActionResultReponese <string>(result, "Insert that bai", "Students"));
        }