76
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
5
public class Program
6
{
7
public static void Main()
8
{
9
List<Transaction> transactions = new List<Transaction>
10
{
11
// These transactions should trigger the suspicious activity for CustomerID 1
12
new Transaction { TransactionID = 1, CustomerID = 1, Timestamp = DateTime.Now.AddDays(-2).AddHours(-1), Amount = 10500m, TransactionType = "Deposit" },
13
new Transaction { TransactionID = 2, CustomerID = 1, Timestamp = DateTime.Now.AddDays(-2).AddHours(1), Amount = 11000m, TransactionType = "Deposit" },
14
new Transaction { TransactionID = 3, CustomerID = 1, Timestamp = DateTime.Now.AddDays(-2).AddHours(2), Amount = 12000m, TransactionType = "Withdrawal" },
15
// Other transactions not triggering the suspicious activity
16
new Transaction { TransactionID = 4, CustomerID = 2, Timestamp = DateTime.Now.AddMonths(-2), Amount = 5000m, TransactionType = "Deposit" },
17
new Transaction { TransactionID = 5, CustomerID = 2, Timestamp = DateTime.Now.AddDays(-15), Amount = 7000m, TransactionType = "Withdrawal" },
18
};
19
20
21
// Step 1: Calculate the total number and total amount of transactions for each type
22
var transactionsByType = transactions
23
.GroupBy(t => t.TransactionType)
24
.Select(g => new
Cached Result
Not nullable False
Nullable
Nullable