src/main/java/seedu/address/logic/commands/commandUnassign/UnassignTeacherFromCourseCommand.java
@Override
    protected void preprocessUndoableCommand(Model model) throws CommandException {
        ID courseID = this.assignDescriptor.getAssignID(PREFIX_COURSEID);
        ID staffID = this.assignDescriptor.getAssignID(PREFIX_TEACHERID);

        boolean courseExists = model.has(courseID, Constants.ENTITY_TYPE.COURSE);
        boolean staffExists = model.has(staffID, Constants.ENTITY_TYPE.STAFF);

        if (!courseExists) {
            throw new CommandException(MESSAGE_INVALID_COURSE_ID);
        } else if (!staffExists) {
            throw new CommandException(MESSAGE_INVALID_TEACHER_ID);
        } else {
            Course foundCourse = (Course) model.get(courseID, Constants.ENTITY_TYPE.COURSE);
            Staff foundStaff = (Staff) model.get(staffID, Constants.ENTITY_TYPE.STAFF);

            boolean assignedCourseContainsStaff = foundCourse.containsStaff(staffID);
            boolean assigningStaffContainsCourse = foundStaff.containsCourse(courseID);

            if (!assignedCourseContainsStaff) {
                throw new CommandException("This course doesn't have the specified teacher! :(");
            } else if (!assigningStaffContainsCourse) {
                throw new CommandException("The teacher isn't even assigned to this course! :(");
            }
        }
    }
/**
     * This performs all two main action to ensure successful Unassigning of Teacher from Course and that
     * the command can undo & redo successfully.
     * 1. Check to ensure that the targeted Teacher & Course exists.
     *
     * @param model the model.
     */
This performs all two main action to ensure successful Unassigning of Teacher from Course and that
the command can undo & redo successfully.
1. Check to ensure that the targeted Teacher & Course exists.

@param model the model.
This performs all two main action to ensure successful Unassigning of Teacher from Course and that the command can undo & redo successfully . 1 . Check to ensure that the targeted Teacher & Course exists . @param model the model .
@Override
    protected void preprocessUndoableCommand(Model model) throws CommandException {
        ID courseID = this.assignDescriptor.getAssignID(PREFIX_COURSEID);
        ID staffID = this.assignDescriptor.getAssignID(PREFIX_TEACHERID);
        boolean courseExists = model.has(courseID, Constants.ENTITY_TYPE.COURSE);
        boolean staffExists = model.has(staffID, Constants.ENTITY_TYPE.STAFF);
        if (!courseExists) {
            throw new CommandException(MESSAGE_INVALID_COURSE_ID);
        } else if (!staffExists) {
            throw new CommandException(MESSAGE_INVALID_TEACHER_ID);
        } else {
            Course foundCourse = (Course) model.get(courseID, Constants.ENTITY_TYPE.COURSE);
            Staff foundStaff = (Staff) model.get(staffID, Constants.ENTITY_TYPE.STAFF);
            boolean assignedCourseContainsStaff = foundCourse.containsStaff(staffID);
            boolean assigningStaffContainsCourse = foundStaff.containsCourse(courseID);
            if (!assignedCourseContainsStaff) {
                throw new CommandException("This course doesn't have the specified teacher! :(");
            } else if (!assigningStaffContainsCourse) {
                throw new CommandException("The teacher isn't even assigned to this course! :(");
            }
        }
    }
@ Override protected void preprocessUndoableCommand ( Model model ) throws CommandException { ID courseID = this . assignDescriptor . getAssignID ( PREFIX_COURSEID ) ; ID staffID = this . assignDescriptor . getAssignID ( PREFIX_TEACHERID ) ; boolean courseExists = model . has ( courseID , Constants . ENTITY_TYPE . COURSE ) ; boolean staffExists = model . has ( staffID , Constants . ENTITY_TYPE . STAFF ) ; if ( ! courseExists ) { throw new CommandException ( MESSAGE_INVALID_COURSE_ID ) ; } else if ( ! staffExists ) { throw new CommandException ( MESSAGE_INVALID_TEACHER_ID ) ; } else { Course foundCourse = ( Course ) model . get ( courseID , Constants . ENTITY_TYPE . COURSE ) ; Staff foundStaff = ( Staff ) model . get ( staffID , Constants . ENTITY_TYPE . STAFF ) ; boolean assignedCourseContainsStaff = foundCourse . containsStaff ( staffID ) ; boolean assigningStaffContainsCourse = foundStaff . containsCourse ( courseID ) ; if ( ! assignedCourseContainsStaff ) { throw new CommandException ( "This course doesn't have the specified teacher! :(" ) ; } else if ( ! assigningStaffContainsCourse ) { throw new CommandException ( "The teacher isn't even assigned to this course! :(" ) ; } } }
This performs all two main action to ensure successful Unassigning of Teacher from Course and that
 the command can undo & redo successfully.
This performs all two main action to ensure successful Unassigning of Teacher from Course and that the command can undo & redo successfully .