コード例 #1
0
        static void Main(string[] args)
        {
            UserAccount userAccount = UserAccountDataCapture.CaptureFirstName();

            userAccount = UserAccountDataCapture.CaptureLastName();

            bool isUserAccountValid = UserAccountValidator.Validate(userAccount);

            if (!isUserAccountValid)
            {
                StandardMessages.EndApplication();
                return;
            }

            AccountGenerator.CreateAccount(userAccount);
            StandardMessages.EndApplication();
        }
        public static bool Validate(UserAccount userAccount)
        {
            bool isValid;

            if (string.IsNullOrWhiteSpace(userAccount.FirstName))
            {
                StandardMessages.DisplayValidationError("First name");
                UserAccountDataCapture.CaptureFirstName();
                isValid = string.IsNullOrWhiteSpace(userAccount.FirstName) ? false : true;
            }
            if (string.IsNullOrWhiteSpace(userAccount.LastName))
            {
                StandardMessages.DisplayValidationError("Last name");
                UserAccountDataCapture.CaptureLastName();
                isValid = string.IsNullOrWhiteSpace(userAccount.LastName) ? false : true;
            }
            else
            {
                isValid = true;
            }

            return(isValid);
        }