public async Task <List <CardOperation> > ExecuteAsync() { Console.WriteLine($"Операция: {_operationStringView.GetView(_operation)}"); var resultOperationsList = new List <CardOperation>(); int resultOperationsCount = 1; if (ConsoleExtensions.AskYesNo("Разбить на несколько?")) { Console.WriteLine("Введите количество операций, на которое надо разбить эту"); resultOperationsCount = ConsoleExtensions.ReadIntOrRetry(); } var moneyLeft = _operation.Amount; for (int i = 0; i < resultOperationsCount; i++) { var newOperation = _operation.Clone(); if (i > 0) { newOperation.Id = Guid.Empty; } newOperation.Amount = moneyLeft; // Get suggestions for operation properties based on existing operations in DB with the same original name var operationNameSuggestions = await _dbLogicManager.GetOperationNameSuggestions(_operation.OriginalName); var operationCategoriesSuggestions = await _dbLogicManager.GetOperationCategoriesSuggestions(_operation.OriginalName); Console.WriteLine($"Операция: {_operationStringView.GetView(newOperation)}"); if (ConsoleExtensions.AskYesNo("Редактировать?")) { EditProperty("Имя операции", newOperation.UserDefinedName ?? newOperation.OriginalName, (value) => { newOperation.UserDefinedName = value; }, operationNameSuggestions); EditProperty("Дата", newOperation.DateTime, (value) => { DateTime parsedValue; if (DateTime.TryParse(value, out parsedValue)) { newOperation.DateTime = parsedValue; } }); EditProperty("Категории", string.Join(",", newOperation.Categories), (value) => newOperation.Categories = value.Split(',').Select(c => c.Trim().ToUpper()).ToHashSet(), operationCategoriesSuggestions); EditOperationAmount(newOperation); } resultOperationsList.Add(newOperation); moneyLeft -= newOperation.Amount; } return(resultOperationsList); }
private void RenderOperations(List <CardOperation> operations) { foreach (var op in operations) { Console.WriteLine($"{operations.IndexOf(op) + 1}. {_cardOperationStringView.GetView(op)}"); } }
private void RenderOperationsInfo(List <CardOperation> operations) { foreach (var op in operations) { Console.WriteLine(_cardOperationView.GetView(op)); } }
private void RenderOperationsAndTotal(List <CardOperation> operations) { operations = operations.OrderBy(op => op.DateTime).ToList(); foreach (var op in operations) { Console.WriteLine($"{operations.IndexOf(op) + 1}. {_cardOperationStringView.GetView(op)}"); } var total = operations.Sum(op => op.Amount); Console.WriteLine($"Всего потрачено/получено: {total}"); }
private void RenderOperations(List<CardOperation> operations, OperationSetStatistics statistics) { if (operations.Any()) { foreach (var operation in operations) { Console.WriteLine(_cardOperationStringView.GetView(operation)); } Console.Write(_cardOperationSetStatisticsStringView.GetView(statistics)); } else { Console.WriteLine("Не найдено операций по запросу"); } }