-
Notifications
You must be signed in to change notification settings - Fork 5k
/
SampleCustomer.cs
43 lines (34 loc) · 1.22 KB
/
SampleCustomer.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace customer_relationship
{
public class SampleCustomer : ICustomer
{
public SampleCustomer(string name, DateTime dateJoined) =>
(Name, DateJoined) = (name, dateJoined);
private List<IOrder> allOrders = new List<IOrder>();
public IEnumerable<IOrder> PreviousOrders => allOrders;
public DateTime DateJoined { get; }
public DateTime? LastOrder { get; private set; }
public string Name { get; }
private Dictionary<DateTime, string> reminders = new Dictionary<DateTime, string>();
public IDictionary<DateTime, string> Reminders => reminders;
public void AddOrder(IOrder order)
{
if (order.Purchased > (LastOrder ?? DateTime.MinValue))
LastOrder = order.Purchased;
allOrders.Add(order);
}
// <SnippetOverrideAndExtend>
public decimal ComputeLoyaltyDiscount()
{
if (PreviousOrders.Any() == false)
return 0.50m;
else
return ICustomer.DefaultLoyaltyDiscount(this);
}
// </SnippetOverrideAndExtend>
}
}