-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAlertService.cs
More file actions
43 lines (35 loc) · 844 Bytes
/
AlertService.cs
File metadata and controls
43 lines (35 loc) · 844 Bytes
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
using System.Collections.Generic;
using System;
public interface IAlertDAO {
Guid AddAlert(DateTime time);
DateTime GetAlert(Guid id);
}
public class AlertService
{
private readonly IAlertDAO storage;
public AlertService(IAlertDAO item){
storage = item;
}
public Guid RaiseAlert()
{
return this.storage.AddAlert(DateTime.Now);
}
public DateTime GetAlertTime(Guid id)
{
return this.storage.GetAlert(id);
}
}
public class AlertDAO: IAlertDAO
{
private readonly Dictionary<Guid, DateTime> alerts = new Dictionary<Guid, DateTime>();
public Guid AddAlert(DateTime time)
{
Guid id = Guid.NewGuid();
this.alerts.Add(id, time);
return id;
}
public DateTime GetAlert(Guid id)
{
return this.alerts[id];
}
}