using System.Collections.Generic;
using System.Threading.Tasks;
private static List<SalesRecord> salesRecords = new();
public static void Main()
var currentServiceProvider = "AWS";
var accManager = GetAccountManager(currentServiceProvider);
Console.WriteLine("Enter User ID:");
var userId = Console.ReadLine();
Console.WriteLine("Enter Password:");
var password = Console.ReadLine();
for (var i = 0; i < 10000; i++)
var item = i < 4000 ? "A" : i < 8000 ? "B" : "C";
salesRecords.Add(new SalesRecord(item));
Parallel.ForEach(salesRecords, r => {
Console.WriteLine("Which item do you want to view? (A/B/C):");
var chosenItem = Console.ReadLine();
IEnumerable<SalesRecord> salesRecordQuery =
from salesRecord in salesRecords
orderby salesRecord.Qty descending
where salesRecord.Item == chosenItem
foreach(SalesRecord record in salesRecordQuery){
Console.WriteLine("{0}, {1}", record.Item, record.Qty);
public static IAccountManager GetAccountManager(string serviceProvider)
return new AzureAuthent();
public string Item { get; set; }
public SalesRecord(string item)
public interface IAccountManager
public bool Authenticate(string userId, string password);
public bool Authenticate(string userId, string password)
return userId == "aws" && password == "abc123";
public bool DeleteUser(string userId)
public class AzureService
public bool AuthUser(string userId, string password)
return userId == "azure" && password == "abc321";
public bool RemoveUser(string userId)
public class AwsAuthent : IAccountManager
private AwsService service = new AwsService();
public bool Authenticate(string userId, string password)
return service.Authenticate(userId, password);
public class AzureAuthent : IAccountManager
private AzureService service = new AzureService();
public bool Authenticate(string userId, string password)
return service.AuthUser(userId, password);