-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransactionSearcher.cs
More file actions
25 lines (16 loc) · 1010 Bytes
/
TransactionSearcher.cs
File metadata and controls
25 lines (16 loc) · 1010 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
using System.Globalization;
public class TransactionSearcher {
public List<Transaction> SearchByYear(DateTime date, List<Transaction> transactions) {
return transactions.Where(t => t.Date.Year == date.Year).ToList();
}
public List<Transaction> SearchByMonth(DateTime date, List<Transaction> transactions) {
return transactions.Where(t => t.Date.Year == date.Year && t.Date.Month == date.Month).ToList();
}
public List<Transaction> SearchByWeek(int year, int week, List<Transaction> transactions) {
Calendar calendar = CultureInfo.InvariantCulture.Calendar;
return transactions.Where(t => t.Date.Year == year && calendar.GetWeekOfYear(t.Date, CalendarWeekRule.FirstDay, DayOfWeek.Monday) == week).ToList();
}
public List<Transaction> SearchByDay(DateTime date, List<Transaction> transactions) {
return transactions.Where(t => t.Date.Year == date.Year && t.Date.Month == date.Month && t.Date.Day == date.Day).ToList();
}
}