Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public AssignmentController(ModuleService moduleService, AssignmentRepository as
}

@PostMapping("")
public ResponseEntity<String> createAssignment(
public ResponseEntity<?> createAssignment(
@RequestBody CreateAssignmentDto assignmentDto,
@AuthenticationPrincipal UserEntity user
) {
Expand All @@ -56,11 +56,10 @@ public ResponseEntity<String> createAssignment(
assignment.setDueDate(assignmentDto.getDueDate());
assignment.setModule(moduleEntity);
try {
assignmentRepository.save(assignment);
return new ResponseEntity<>("Assignment created", HttpStatus.CREATED);
return new ResponseEntity<>(assignmentRepository.save(assignment), HttpStatus.CREATED);
} catch (Exception e) {
System.out.println(e.getMessage());
return new ResponseEntity<>("Unable to create assignment", HttpStatus.INTERNAL_SERVER_ERROR);
return new ResponseEntity<>("Error: Unable to create assignment!", HttpStatus.INTERNAL_SERVER_ERROR);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public ResponseEntity<List<ClassDto>> getClasses(
}

@PostMapping("")
public ResponseEntity<String> createClass(
public ResponseEntity<?> createClass(
@RequestBody CreateClassDto classDto,
@AuthenticationPrincipal UserEntity user
) {
Expand All @@ -80,8 +80,7 @@ public ResponseEntity<String> createClass(
classEntity.setHomeroomTeacher(teacher);
classEntity.setSchool(school);
try {
classRepository.save(classEntity);
return new ResponseEntity<>("Class created", HttpStatus.CREATED);
return new ResponseEntity<>(classRepository.save(classEntity), HttpStatus.CREATED);
} catch (Exception e) {
System.out.println(e.getMessage());
return new ResponseEntity<>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public ResponseEntity<List<CourseDto>> getCourses(
}

@PostMapping("")
public ResponseEntity<String> createCourse(
public ResponseEntity<?> createCourse(
@RequestBody CreateCourseDto courseDto,
@AuthenticationPrincipal UserEntity user
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public MaterialController(ModuleService moduleService, MaterialRepository materi
}

@PostMapping("")
public ResponseEntity<String> createMaterial(
public ResponseEntity<?> createMaterial(
@RequestBody CreateMaterialDto createMaterialDto,
@AuthenticationPrincipal UserEntity user
) {
Expand All @@ -49,8 +49,7 @@ public ResponseEntity<String> createMaterial(
material.setUrl(createMaterialDto.getUrl());
material.setModule(moduleEntity);
try {
materialRepository.save(material);
return new ResponseEntity<>("Material created", HttpStatus.CREATED);
return new ResponseEntity<>(materialRepository.save(material), HttpStatus.CREATED);
} catch (Exception e) {
System.out.println(e.getMessage());
return new ResponseEntity<>("Unable to create material", HttpStatus.INTERNAL_SERVER_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ModuleController(final ModuleRepository moduleRepository, final ModuleSer
}

@PostMapping("")
public ResponseEntity<String> createModule(
public ResponseEntity<?> createModule(
@RequestBody CreateModuleDto createModuleDto,
@AuthenticationPrincipal UserEntity user
) {
Expand All @@ -49,8 +49,8 @@ public ResponseEntity<String> createModule(
moduleEntity.setName(createModuleDto.getName());
moduleEntity.setCourse(course);
try {
moduleRepository.save(moduleEntity);
return new ResponseEntity<>("Module created", HttpStatus.CREATED);

return new ResponseEntity<>(moduleRepository.save(moduleEntity), HttpStatus.CREATED);
} catch (Exception e) {
System.out.println(e.getMessage());
return new ResponseEntity<>("Unable to create module", HttpStatus.INTERNAL_SERVER_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ public class ScheduleController {
private ScheduleService scheduleService;

@PostMapping("")
public ResponseEntity<String> createSchedule(@RequestBody CreateScheduleDto createScheduleDto) {
public ResponseEntity<?> createSchedule(@RequestBody CreateScheduleDto createScheduleDto) {
try
{
scheduleService.createSchedule(createScheduleDto);
return new ResponseEntity<String>("Schedule was successfully created!", HttpStatus.CREATED);
return new ResponseEntity<>(scheduleService.createSchedule(createScheduleDto), HttpStatus.CREATED);
} catch (Exception e)
{
return new ResponseEntity<String>("Error " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
return new ResponseEntity<>("Error " + e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,12 @@ public ResponseEntity<List<SchoolDto>> getSchools(
}

@PostMapping("")
public ResponseEntity<String> createSchool(@RequestBody CreateSchoolDto schoolDto) {
public ResponseEntity<?> createSchool(@RequestBody CreateSchoolDto schoolDto) {
School school = new School();
school.setName(schoolDto.getName());
school.setAddress(schoolDto.getAddress());
try {
schoolRepository.save(school);
return new ResponseEntity<>("School created", HttpStatus.CREATED);
return new ResponseEntity<>(schoolRepository.save(school), HttpStatus.CREATED);
} catch (Exception e) {
System.out.println(e.getMessage());
return new ResponseEntity<>("Unable to create school", HttpStatus.BAD_REQUEST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public SubmissionController(AssignmentService assignmentService, SubmissionRepos
}

@PostMapping("")
public ResponseEntity<String> createSubmission(
public ResponseEntity<?> createSubmission(
@RequestBody CreateSubmissionDto submissionDto,
@AuthenticationPrincipal UserEntity user
) {
Expand All @@ -48,8 +48,7 @@ public ResponseEntity<String> createSubmission(
submission.setStudent(user);
submission.setAssignment(assignment);
try {
submissionRepository.save(submission);
return new ResponseEntity<>("Submission created", HttpStatus.CREATED);
return new ResponseEntity<>(submissionRepository.save(submission), HttpStatus.CREATED);
} catch (Exception e) {
System.out.println(e.getMessage());
return new ResponseEntity<>("Unable to create submission", HttpStatus.INTERNAL_SERVER_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public void deleteRelations(Course course) {
schoolRepository.save(school);
}

public ResponseEntity<String> createCourse(CreateCourseDto courseDto, UserEntity user) {
public ResponseEntity<?> createCourse(CreateCourseDto courseDto, UserEntity user) {
School school = schoolRepository.findById(courseDto.getSchoolId())
.orElseGet(() -> user.getSchool());

Expand All @@ -171,8 +171,7 @@ public ResponseEntity<String> createCourse(CreateCourseDto courseDto, UserEntity
course.setTeachers(teachers);
}
try {
courseRepository.save(course);
return new ResponseEntity<>("Course created", HttpStatus.CREATED);
return new ResponseEntity<>(courseRepository.save(course), HttpStatus.CREATED);
} catch (Exception e) {
return new ResponseEntity<>("Unable to create course", HttpStatus.INTERNAL_SERVER_ERROR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ScheduleService {
@Autowired
private CourseRepository courseRepository;

public void createSchedule(CreateScheduleDto createScheduleDTO) {
public Schedule createSchedule(CreateScheduleDto createScheduleDTO) {
Optional<ClassEntity> classEntityOpt = classRepository.findById(createScheduleDTO.getClassId());
Optional<Course> courseOpt = courseRepository.findById(createScheduleDTO.getCourseId());

Expand All @@ -55,7 +55,7 @@ public void createSchedule(CreateScheduleDto createScheduleDTO) {
schedule.setEndTime(createScheduleDTO.getEndTime());
schedule.setRoomNumber(createScheduleDTO.getRoomNumber());

scheduleRepository.save(schedule);
return scheduleRepository.save(schedule);
}

public List<Schedule> getAllSchedules() {
Expand Down