예제 #1
0
        // technical validation carried out at the application level
        private void Validate(NewAccount account)
        {
            if (!account.Email.Contains("@"))
                throw new ValidationFailure("Not a valid email address");

            if (account.Email.Length >= 50)
                throw new ValidationFailure("Email address must be less than 50 characters");

            if (account.Nickname.Length >= 25)
                throw new ValidationFailure("Nickname must be less than 25 characters");

            if (String.IsNullOrWhiteSpace(account.Email))
                throw new ValidationFailure("You must supply an email");

            if (String.IsNullOrWhiteSpace(account.Nickname))
                throw new ValidationFailure("You must supply a Nickname");
        }
예제 #2
0
        public void RecommendAFriend(int referrerId, NewAccount friendsAccountDetails)
        {
            Validate(friendsAccountDetails);

            // most technologies have similar transaction APIs
            using (var transaction = new System.Transactions.TransactionScope())
            {
                try
                {
                    // ... interact with domain multiple times
                    transaction.Complete();
                }
                catch
                {
                    // transaction will roll back if Complete() not called
                }
            }
        }
예제 #3
0
        public void RecommendAFriend(int referrerId, NewAccount friendsAccountDetails)
        {
            Validate(friendsAccountDetails);

            // most technologies have similar transaction APIs
            using (var transaction = new System.Transactions.TransactionScope())
            {
                try
                {
                    // ... interact with domain multiple times
                    transaction.Complete();
                }
                catch
                {
                    // transaction will roll back if Complete() not called
                }
            }
        }