private static void ChangeOrDeleteExpediture() { Console.WriteLine("Выполняется корректировка трат.\nНа данный момент зарегистрированы следующие пользователи: "); Person person = ChoicePerson(); if (person != null) { Console.WriteLine($"Выбран пользователь: {person.FirstName} {person.LastName}" + $"У данного пользователя есть следующие траты:"); Expenditure expediture = ChoiceExpenditure(person); if (expediture != null) { bool flag = false; do { Console.WriteLine(@"Выберете следующее действие: 1.Корректировать трату 2.Удалить трату 3.Назад"); switch (Console.ReadLine()) { case "1": ChangeExpenditure(expediture); // Корректировать трату break; case "2": AppFunctioality.RemoveExpenditure(expediture); // Удалить трату break; case "3": break; default: flag = true; Console.WriteLine("Введенно некорректное значение"); break; } } while (flag); } else { Console.WriteLine("Данной тараты у данного пользователя не обнаружено."); } } else { Console.WriteLine("Пользователя с таким Id не обнаруженно"); } }
// Корректировка траты private static void ChangeExpenditure(Expenditure expenditure) { Console.WriteLine($"\n\nТрата пользователя {expenditure.Person.FirstName} {expenditure.Person.LastName} имеет следующие параметры:\n" + $"Sum - {expenditure.TotalSum};\nDate - {expenditure.Date};\nCategory - {expenditure.Category};\n" + $"и содержит следующие продукты:"); AppFunctioality.ToPrintProduct(expenditure); decimal newSum; Console.WriteLine("Введите новое значение Sum:"); while (!Decimal.TryParse(Console.ReadLine(), out newSum)) { ; } char newCat; Console.WriteLine("Введите новое значение категории товара:"); while (!Char.TryParse(Console.ReadLine(), out newCat)) { Console.WriteLine("Выберете новое значение Date:"); } DateTime newDate = ImputDateFull(); if (newSum != expenditure.TotalSum) { AppFunctioality.RemoveExpenditure(expenditure); AppFunctioality.AddExpenditure(expenditure.Person.PersonId, newCat, newSum, newDate); Console.WriteLine("Введите обновленные данные о товарах:"); AddProducts(newDate, newSum); } else { AppFunctioality.ChangeExpenditure(expenditure, newCat, newSum, newDate); } }