public async Task <ResponseDto> Create([FromBody] CreateStudentRequestDto request) { if (!ModelState.IsValid) { return(new ResponseDto(ResponseCode.Validate, "Đầu vào không hợp lệ")); } var studentId = await _studentService.Create(request); if (studentId == 0) { return(new ResponseDto(ResponseCode.LogicError, "Tạo mới không thành công")); } return(new ResponseDto(ResponseCode.Success, "Tạo mới thành công")); }
/// <summary> /// Thêm mới HS /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <int> Create(CreateStudentRequestDto request) { var student = new Student() { BusId = request.BusId, ParentId = request.ParentId, StopPickId = request.StopPickId, StopDropId = request.StopDropId, Name = request.Name, Address = request.Address, Dob = request.Dob, Email = request.Email, PhoneNumber = request.PhoneNumber, Status = 0, ClassOfStudent = request.ClassOfStudent, TeacherId = request.TeacherId }; await _context.Students.AddAsync(student); await _context.SaveChangesAsync(); return(student.Id); }