private static operation GetMaxAmount(List <operation> listOfOperations) { //assuming the first file contains the maximum value for the "Amount" field operation max = listOfOperations.First(); for (int index = 1; index < listOfOperations.Count; index++) { //if the next value from the list is greater than the default one then assign the bigger value maxAmountOperation if (max.Amount < listOfOperations[index].Amount) { max = listOfOperations[index]; } } return(max); }
private static void Process(string type) { //creating a list that will contain all deserialized objects List <operation> listOfOperations = GetListOfOperationsByType(type); //checking if there is at least one valid file in the folder if (listOfOperations.Count < 1) { Console.WriteLine("No operations found"); return; } operation maxAmountOperation = GetMaxAmount(listOfOperations); Console.WriteLine($"Date: {maxAmountOperation.Date:yyyy-MM-dd}, Debit/Credit: {maxAmountOperation.OperationType}, Amount: {maxAmountOperation.Amount}"); Console.WriteLine("----------------------------------------------------"); }