// This method fires when IAsyncResult indicates the task is complete.
    private void EndTask(IAsyncResult ar)
    {
        AsyncQueryResult completedSync = (AsyncQueryResult)ar;

        try
        {
            table = completedSync.Result;

            // Store it in the cache, if needed.
            if (!ar.CompletedSynchronously)
            {
                Cache.Insert("Employees", table, null,
                             DateTime.Now.AddMinutes(5), TimeSpan.Zero);
            }
        }
        catch (Exception err)
        {
            lblError.Text = "An error occurred. <br />";

            // Typically, you wouldn't display the underlying
            // error message.
            // This is a debugging/testing aid.
            lblError.Text += err.Message;
        }
    }
Пример #2
0
        private void ArrangeTrades()
        {
            var trades = new[]
            {
                new Trade
                {
                    Id            = 1,
                    Symbol        = "CBI",
                    Action        = "BUY",
                    ContractPrice = 310.0M,
                    NoOfShares    = 5,
                    PortfolioId   = 1,
                },
                new Trade
                {
                    Id            = 2,
                    Symbol        = "REL",
                    Action        = "BUY",
                    ContractPrice = 230.55M,
                    NoOfShares    = 50,
                    PortfolioId   = 1,
                },
                new Trade
                {
                    Id            = 3,
                    Symbol        = "CBI",
                    Action        = "SELL",
                    ContractPrice = 77.15M,
                    NoOfShares    = 65,
                    PortfolioId   = 2,
                },
                new Trade
                {
                    Id            = 4,
                    Symbol        = "CBI",
                    Action        = "SELL",
                    ContractPrice = 100.15M,
                    NoOfShares    = 12,
                    PortfolioId   = 3,
                },
                new Trade
                {
                    Id            = 5,
                    Symbol        = "CBI",
                    Action        = "SELL",
                    ContractPrice = 104.15M,
                    NoOfShares    = 129,
                    PortfolioId   = 3,
                },
            };
            var entities = new AsyncQueryResult <Trade>(trades);

            _tradeRepositoryMock
            .Setup(mock => mock.Query())
            .Returns(entities);
        }