import 'package:test_sa/models/base.dart';

class DepartmentRoomCombined extends Base {
  final int? deptId;
  final int? roomId;
  final String? deptName;
  final String? roomName;
  final String? locationDescriptionName;
  final String? deptAndRoomName;

  DepartmentRoomCombined({
    this.deptId,
    this.roomId,
    this.deptName,
    this.roomName,
    this.locationDescriptionName,
    this.deptAndRoomName,
  }) : super(
          identifier: '${deptId}_${roomId}',
          name: deptAndRoomName ?? '${deptName ?? ''} / ${roomName ?? ''}',
        );

  factory DepartmentRoomCombined.fromJson(Map<String, dynamic> json) {
    return DepartmentRoomCombined(
      deptId: json['deptId'],
      roomId: json['roomId'],
      deptName: json['deptName'],
      roomName: json['roomName'],
      locationDescriptionName: json['locationDescriptionName'],
      deptAndRoomName: json['deptAndRoomName'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'deptId': deptId,
      'roomId': roomId,
      'deptName': deptName,
      'roomName': roomName,
      'locationDescriptionName': locationDescriptionName,
      'deptAndRoomName': deptAndRoomName,
    };
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      other is DepartmentRoomCombined &&
          runtimeType == other.runtimeType &&
          deptId == other.deptId &&
          roomId == other.roomId;

  @override
  int get hashCode => deptId.hashCode ^ roomId.hashCode;
}
