Esempio n. 1
0
        public ActionResult WithoutFacade()
        {
            var logger       = new Logger();
            var payment      = new Payment();
            var securityInfo = new SecurityInfo();
            var transaction  = new Trasaction();

            logger.Log("Payment Start");
            var result     = false;
            var userId     = "3434343";
            var securityId = securityInfo.GetFromUserId(userId);

            logger.Log($"Security id {securityId} for user id {userId}");
            transaction.Start();
            transaction.Do(() =>
            {
                var amount = 45.400;
                result     = payment.Pay(securityId, amount);
                logger.Log($"Paying {amount} for security id {securityId}");
            });
            transaction.End();
            logger.Log("transaction end");
            logger.Log($"payment result {result}");

            payment.Dispose();
            transaction.Dispose();
            securityInfo.Dispose();
            logger.Dispose();

            return(Content("WithoutFacade"));
        }
        public bool Pay(string userId, double amount)
        {
            _logger.Log("Payment Start");
            var result     = false;
            var securityId = _securityInfo.GetFromUserId(userId);

            _logger.Log($"Security id {securityId} for user id {userId}");
            _transaction.Start();
            _transaction.Do(() =>
            {
                result = _payment.Pay(securityId, amount);
                _logger.Log($"Paying {amount} for security id {securityId}");
            });
            _transaction.End();
            _logger.Log("transaction end");
            _logger.Log($"payment result {result}");
            _payment.Dispose();
            _transaction.Dispose();
            _securityInfo.Dispose();
            _logger.Dispose();

            return(result);
        }