Esempio n. 1
0
        public void InsertEnrty() //2. menu method
        {
            bool   isNameValid, isDateValid, isSalaryValid;
            string inputName, inputSalary, inputDate = "";

            do
            {
inputName:
                Console.WriteLine("Please enter model`s name:");
                inputName   = Console.ReadLine();
                isNameValid = validator.IsNameValid(inputName);
                if (!isNameValid)
                {
                    goto inputName;
                }
inputSalary:
                Console.WriteLine("Please enter model`s salary:");
                inputSalary   = Console.ReadLine();
                isSalaryValid = validator.IsSalaryValid(inputSalary);
                if (!isSalaryValid)
                {
                    goto inputSalary;
                }
inputDate:
                Console.WriteLine("Please enter model`s join date:");
                inputDate   = Console.ReadLine();
                isDateValid = validator.IsDateValid(inputDate);
                if (!isDateValid)
                {
                    goto inputDate;
                }
            }while (!isNameValid || !isSalaryValid || !isDateValid);
            inputName = UppercaseFirst(inputName); //first letter up
            DatabaseModel input = new DatabaseModel()
            {
                Name      = inputName,
                Salary    = double.Parse(inputSalary),
                StartWork = DateTime.Parse(inputDate)
            };

            DatabaseRepository.AddItem(input);
            PrintMenu(true);
            Console.WriteLine("Item added");
        }