public Facade()
 {
     _logger       = new Logger();
     _payment      = new Payment();
     _securityInfo = new SecurityInfo();
     _transaction  = new Trasaction();
 }
示例#2
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"));
        }