public static void AddTransaction() { CurrentUser.PrintCategories(); Console.WriteLine("Enter the ID category of the transaction :"); bool correctChoice = false; int CatId = 0; while (!correctChoice) { try { CatId = Convert.ToInt32(Console.ReadLine()); if (CurrentUser.getCategoriesId().Contains(CatId)) { correctChoice = true; } else { Console.WriteLine("Enter a correct ID :"); } } catch (Exception e) { Debug.WriteLine("Exception : " + e); Console.WriteLine("Enter a correct ID :"); } } Console.WriteLine("Enter the transaction's description :"); string CatDes = Console.ReadLine(); Console.WriteLine("Enter the transaction's date :"); DateTime CatDate = DateTime.Now; correctChoice = false; while (!correctChoice) { try { CatDate = Convert.ToDateTime(Console.ReadLine()); correctChoice = true; } catch (Exception e) { Debug.WriteLine("Exception : " + e); Console.WriteLine("Please enter a correct date format DD/MM/YYYY : "); } } Console.WriteLine("Enter the transaction's amount :"); double CatAmount = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("Is it an expense or gain ? (e/g) :"); bool CatExpense = true; correctChoice = false; while (!correctChoice) { switch (Console.ReadLine()) { case "e": correctChoice = true; break; case "g": correctChoice = true; CatExpense = false; break; default: Console.WriteLine("Please enter 'e' or 'g' :"); break; } } CurrentUser.AddTransact(db.Get <Category>(CatId), CatDes, CatDate, CatAmount, CatExpense); Console.WriteLine("Transaction saved ! Press a key to come back to the transaction menu."); Console.ReadKey(); User.transactionMenu(); }