public void End(object response)
 {
     try
     {
         if (this.IsTransactional)
         {
             this.CompleteTransaction(response);
         }
     }
     finally
     {
         this.UnitOfWork.Dispose();
         this.UnitOfWork = null;
     }
 }
 public virtual void SetUp()
 {
     this.unitOfWork = new UnitOfWork();
     this.transaction = new Transaction();
     this.Session = ServiceLocator.Current.GetInstance<ISession>();
 }
            public void Start()
            {
                this.UnitOfWork = new UnitOfWork();
                if (this.IsTransactional)
                {
                    this.Transaction = new Transaction();
                }

                IApplicationPrincipal principal;
                var session = this.req.GetSession();
                if (session != null && session.IsAuthenticated)
                {
                    var identity = new ApplicationIdentity(
                        long.Parse(session.UserAuthId),
                        session.UserName, 
                        session.DisplayName,
                        session.Email);
                    principal = new ApplicationPrincipal(
                        identity, 
                        session.Roles.ToArray(), 
                        session.Permissions.ToArray());
                }
                else
                {
                    principal = ApplicationPrincipal.Anonymous;
                }

                System.Threading.Thread.CurrentPrincipal = principal;
            }