public int GetCategoryId(IRepositoryFactory repositoryFactory) { bool correctInput = true; string userInput; int id = -1; Console.WriteLine("Enter category ID: "); do { IsWrongInput(correctInput); try { userInput = Console.ReadLine(); id = int.Parse(userInput); correctInput = ValidateInput.IsCorrectCategoryId(id, repositoryFactory, correctInput); } catch (Exception) { correctInput = false; } }while (!correctInput); return(id); }