-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTogglTimeEntry.cs
94 lines (80 loc) · 2.7 KB
/
TogglTimeEntry.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace TogglAPI
{
[DataContract]
public class TogglTimeEntryObj
{
[DataMember(Name = "time_entry")]
public TogglTimeEntry TimeEntry { get; set; }
}
[DataContract]
public class TogglTimeEntry
: Toggl
{
[DataMember(Name = "description")]
public string Name { get; set; }
[DataMember(Name = "wid", EmitDefaultValue = false)]
public int? WorkspaceId { get; set; }
[DataMember(Name = "pid", EmitDefaultValue = false)]
public int? ProjectId { get; set; }
[DataMember(Name = "tid")]
public int TaskId { get; set; }
[DataMember(Name = "billable", EmitDefaultValue = false)]
public bool? Billable { get; set; }
[DataMember(Name = "start")]
public string StartStr { get; set; }
[DataMember(Name = "stop", EmitDefaultValue = false)]
public string StopStr { get; set; }
[DataMember(Name = "duration")]
public int Duration { get; set; }
[DataMember(Name = "created_with")]
public string CreatedWith { get; set; }
[DataMember(Name = "tags")]
public List<string> Tags { get; set; }
public DateTime Start
{
get
{
return Convert.ToDateTime(StartStr);
}
set
{
string append = value.ToString("%K");
if (string.IsNullOrEmpty(append)) append = DateTime.Now.ToString("%K");
StartStr = value.ToString("s", DateTimeFormatInfo.InvariantInfo) + append;
}
}
public DateTime Stop
{
get
{
return Convert.ToDateTime(StopStr);
}
set
{
string append = value.ToString("%K");
if (string.IsNullOrEmpty(append)) append = DateTime.Now.ToString("%K");
StopStr = value.ToString("s", DateTimeFormatInfo.InvariantInfo) + append;
}
}
public TogglTimeEntry(TogglTask task, string description, bool? billable, DateTime start, int duration,
List<string> tags)
{
this.Billable = billable;
this.CreatedWith = "TogglConsole";
this.Duration = duration;
this.Name = description;
this.Start = start;
this.Tags = tags;
//this.WorkspaceId = task.WorkspaceId.Value;
//this.ProjectId = task.ProjectId;
this.TaskId = task.Id.Value;
}
}
}