appointment.dart 1.37 KB
Newer Older
HellLab's avatar
HellLab committed
1
class Appointment {
2
  // constructor
3
  Appointment(this.id, this.name, this.year, this.month, this.day, this.time,
4
      this.duration, this.location, this.note);
5

6
  // leeres Appointment
7
  Appointment.zero();
HellLab's avatar
HellLab committed
8

9
  factory Appointment.fromJson(Map<String, dynamic> appointment) => Appointment(
Mauritz, Falk Marius's avatar
Mauritz, Falk Marius committed
10
      appointment['id'] as int,
11
12
13
14
15
16
      appointment['name'] as String,
      appointment['year'] as int,
      appointment['month'] as int,
      appointment['day'] as int,
      appointment['time'] as String,
      appointment['duration'] as String,
17
18
      appointment['location'] as String,
      appointment['note'] as String);
Siedschlag, Lennart's avatar
Siedschlag, Lennart committed
19

20
  List<String> contactCodes = [];
Siedschlag, Lennart's avatar
Siedschlag, Lennart committed
21
  int id;
HellLab's avatar
HellLab committed
22
  String name;
Siedschlag, Lennart's avatar
Siedschlag, Lennart committed
23
24
25
26
27
  int year;
  int month;
  int day;
  String time = "";
  String duration = "";
Siedschlag, Lennart's avatar
hotfix    
Siedschlag, Lennart committed
28
  String location = "";
29
  String note = "";
HellLab's avatar
HellLab committed
30

HellLab's avatar
hallo    
HellLab committed
31
  Map<String,dynamic> toJson() => {
Mauritz, Falk Marius's avatar
Mauritz, Falk Marius committed
32
        'id' :id,
33
34
35
36
37
38
        'name': name,
        'year': year,
        'month': month,
        "day": day,
        'time': time,
        'duration': duration,
39
40
        'location': location,
        'note': note
41
      };
42

43
44
  ///date like 'yyyy-mm-dd'
  set date(String str) {
Mauritz, Falk Marius's avatar
Mauritz, Falk Marius committed
45
46
47
48
    final List<String> split = str.split("-");
    year = int.parse(split[0]);
    month = int.parse(split[1]);
    day = int.parse(split[2]);
HellLab's avatar
HellLab committed
49
  }
50

51
  String get date {
52
    return "$year-$month-$day";
53
  }
HellLab's avatar
hallo    
HellLab committed
54
55
56
57

  bool equals(Appointment app){
    return this.toJson() == app.toJson();
  }
HellLab's avatar
HellLab committed
58
59
}