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;
using System.Collections.Generic;
using System.Linq;
public class SlotDescription
{
public SlotDescription(string desc, DateTime time)
{
Description = desc;
Time = time;
}
public string Description { get; set; }
public DateTime Time { get; set; }
}
public static class SharedValues
{
public static readonly List<SlotDescription> SlotInformation =
new List<SlotDescription>
{
new SlotDescription ("Thursday, 8:30 AM", Slot1),
new SlotDescription ("Thursday, 9:45 AM", Slot2),
new SlotDescription ("Thursday, 11:00 AM", Slot3),
new SlotDescription ("Thursday, 1:00 PM", Slot4),
new SlotDescription ("Thursday, 2:45 PM", Slot5),
new SlotDescription ("Thursday, 3:30 PM", Slot6)
};
public static readonly DateTime Slot1 = new DateTime(2017, 8, 3, 8, 30, 0);
public static readonly DateTime Slot2 = new DateTime(2017, 8, 3, 9, 45, 0);
public static readonly DateTime Slot3 = new DateTime(2017, 8, 3, 11, 0, 0);
public static readonly DateTime Slot4 = new DateTime(2017, 8, 3, 13, 0, 0);
public static readonly DateTime Slot5 = new DateTime(2017, 8, 3, 14, 15, 0);
public static readonly DateTime Slot6 = new DateTime(2017, 8, 3, 15, 30, 0);
}
public static class Program
{
public static SlotDescription GetNextSlot(DateTime start) =>
SharedValues
.SlotInformation
.OrderBy(sv => sv.Time)
.FirstOrDefault(sv => sv.Time >= start);
public static void Main()
{
var date = new DateTime(2017, 8, 3, 8, 45, 00);
var nextSlot = GetNextSlot(date);
Console.WriteLine("Next Slot: " + nextSlot.Description);
}
}