-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQueryExecution.cs
More file actions
43 lines (38 loc) · 913 Bytes
/
QueryExecution.cs
File metadata and controls
43 lines (38 loc) · 913 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;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using CandidateExercises.Core;
namespace CandidateExercises.LINQ
{
class CustomerMailer
{
private readonly IEmailer _emailer = null; // Assume assigned
public void MailCustomers()
{
var customers = GetAllCustomers();
if (customers.Count() > 0)
{
SendEmail(customers);
}
}
private void SendEmail(IEnumerable<Customer> customers)
{
foreach (var customer in customers)
{
_emailer.SendEmail(customer.EmailAddress, "Buy my stuff!");
}
}
private IEnumerable<Customer> GetAllCustomers()
{
return from c in GetCustomersFromDatabase()
select new Customer();
}
private IEnumerable<DbCustomer> GetCustomersFromDatabase()
{
// Assume implemented using a data reader approach
return null;
}
}
}