public async Task <IActionResult> DeteleStuClass(int id)
        {
            var stuclass = await _stuClassService.GetTById(id);

            if (stuclass == null)
            {
                return(NotFound());
            }
            _stuClassService.DeleteT(stuclass);
            if (!await _stuClassService.Save())
            {
                return(StatusCode(500, "删除班级信息失败"));
            }
            return(NoContent());
        }
Exemple #2
0
        public async Task <IActionResult> AddStudentToClass(int StuId, int StuClassId)
        {
            var stu = await _studentService.GetStudentDetailById(StuId);

            if (stu == null)
            {
                return(BadRequest("该学生不存在"));
            }
            var cls = await _stuClassService.GetTById(StuClassId);

            if (cls == null)
            {
                return(BadRequest("该班级不存在"));
            }
            if (stu.StuClass != null)
            {
                return(BadRequest("该学生已分班"));
            }
            stu.StuClass = cls;
            var res      = _mapper.Map <AddStudentToClassDto>(stu);
            var stuclass = _mapper.Map(res, stu);

            if (!await _studentService.Save())
            {
                return(StatusCode(500, "添加失败"));
            }
            return(Created("", null));
        }