Ejemplo n.º 1
0
        public IActionResult InsertStudentMeta(StudentMetaQO newStudentMetaQO)
        {
            SuccessVO success = new SuccessVO
            {
                IsSuccess = _adminService.InsertStudentMeta(newStudentMetaQO)
            };

            return(Ok(success));
        }
Ejemplo n.º 2
0
        public IActionResult UpdateStudentMeta([FromBody] StudentMetaQO newStudentMeta)
        {
            SuccessVO success = new SuccessVO
            {
                IsSuccess = _adminService.UpdateStudentMeta(newStudentMeta)
            };

            return(Ok(success));
        }
Ejemplo n.º 3
0
        public bool UpdateStudentMeta(StudentMetaQO newStudentMeta)
        {
            var studentMeta = _context.StudentMeta.Find(newStudentMeta.Number);

            if (studentMeta == null)
            {
                return(false);                    //如果找不到该学号的学生就更新失败
            }
            _context.StudentMeta.Attach(studentMeta);
            studentMeta.Name   = newStudentMeta.Name;
            studentMeta.Major  = newStudentMeta.Major;
            studentMeta.Grade  = newStudentMeta.Grade;
            studentMeta.Status = newStudentMeta.Status;
            _context.SaveChanges();
            return(true);
        }
Ejemplo n.º 4
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);
        }