-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppointmentExtensions.cs
More file actions
52 lines (48 loc) · 1.48 KB
/
Copy pathAppointmentExtensions.cs
File metadata and controls
52 lines (48 loc) · 1.48 KB
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
using System.Text;
using SyncWhole.Common;
namespace SyncWhole
{
internal static class AppointmentExtensions
{
public static string ToLongString(this ILoadedAppointment appointment)
{
var sb = new StringBuilder();
sb.AppendLine(appointment.UniqueId);
sb.AppendLine();
sb.AppendLine(appointment.Busy ? "Busy" : "Free");
if (!appointment.Confirmed)
{
sb.AppendLine("Tentative");
}
sb.AppendLine(appointment.Subject);
sb.AppendLine(appointment.Location);
sb.AppendLine();
if (appointment.Schedule == null)
{
sb.AppendLine("No schedule");
}
else if (appointment.Schedule.AllDay && appointment.Schedule.Start.Date.AddDays(1) == appointment.Schedule.End.Date)
{
sb.AppendLine($"{appointment.Schedule.Start.ToShortDateString()}");
}
else if (appointment.Schedule.AllDay)
{
sb.AppendLine($"{appointment.Schedule.Start.ToShortDateString()} - {appointment.Schedule.End.AddDays(-1).ToShortDateString()}");
}
else if (appointment.Schedule.Start.Date == appointment.Schedule.End.Date)
{
sb.AppendLine($"{appointment.Schedule.Start} - {appointment.Schedule.End.ToShortTimeString()}");
}
else
{
sb.AppendLine($"{appointment.Schedule.Start} - {appointment.Schedule.End}");
}
if (appointment.Schedule?.Recurrence != null)
{
sb.AppendLine();
sb.AppendLine($"{appointment.Schedule.Recurrence.Frequency} recurrence!");
}
return sb.ToString();
}
}
}