You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			61 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Dart
		
	
			
		
		
	
	
			61 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Dart
		
	
import 'package:test_sa/models/new_models/room_model.dart';
 | 
						|
 | 
						|
import '../base.dart';
 | 
						|
 | 
						|
class Department extends Base {
 | 
						|
  Department({
 | 
						|
    this.id,
 | 
						|
    this.departmentName,
 | 
						|
    this.departmentCode,
 | 
						|
    this.departmentId,
 | 
						|
    this.ntCode,
 | 
						|
    this.rooms,
 | 
						|
  }) : super(identifier: id.toString(), name: departmentName);
 | 
						|
 | 
						|
  Department.fromJson(dynamic json) {
 | 
						|
    id = json['id'];
 | 
						|
    identifier = id.toString();
 | 
						|
    departmentName = json['departmentName'] ?? json['name'];
 | 
						|
    name = departmentName;
 | 
						|
    departmentCode = json['departmentCode'];
 | 
						|
    departmentId = json['departmentId'];
 | 
						|
    ntCode = json['ntCode'];
 | 
						|
    rooms = <Rooms>[];
 | 
						|
    if (json['rooms'] != null) {
 | 
						|
      json['rooms'].forEach((v) {
 | 
						|
        rooms.add(Rooms.fromJson(v));
 | 
						|
      });
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  num id;
 | 
						|
  String departmentName;
 | 
						|
  String departmentCode;
 | 
						|
  String departmentId;
 | 
						|
  String ntCode;
 | 
						|
 | 
						|
  List<Rooms> rooms;
 | 
						|
 | 
						|
  Department copyWith({num id, String departmentName, String departmentCode, String ntCode, List<Rooms> rooms}) => Department(
 | 
						|
        id: id ?? this.id,
 | 
						|
        departmentName: departmentName ?? this.departmentName,
 | 
						|
        departmentCode: departmentCode ?? this.departmentCode,
 | 
						|
        departmentId: departmentId ?? this.departmentId,
 | 
						|
        ntCode: ntCode ?? this.ntCode,
 | 
						|
        rooms: rooms ?? this.rooms,
 | 
						|
      );
 | 
						|
 | 
						|
  Map<String, dynamic> toJson() {
 | 
						|
    final map = <String, dynamic>{};
 | 
						|
    map['id'] = id;
 | 
						|
    map['departmentName'] = departmentName;
 | 
						|
    map['departmentCode'] = departmentCode;
 | 
						|
    map['departmentId'] = departmentId;
 | 
						|
    map['ntCode'] = ntCode;
 | 
						|
    if (rooms != null) {
 | 
						|
      map['rooms'] = rooms.map((v) => v.toJson()).toList();
 | 
						|
    }
 | 
						|
    return map;
 | 
						|
  }
 | 
						|
}
 |