示例#1
0
        // Approve proposal (check risk, bank balance, etc)
        public async Task Handle(StockQuotationProposal arrivedProposal, CancellationToken cancellationToken)
        {
            if (arrivedProposal._ownerId != _id)
            {
                return;
            }

            // Instructions to approve proposal

            var stockQuotation = new StockQuotation(arrivedProposal);

            _newYorkStockExchange.Publish(stockQuotation).Wait();

            if (!stockQuotation._isExecuted)
            {
                _brokerRepository.Add(stockQuotation);
            }
        }
示例#2
0
        public async Task Handle(StockQuotation arrivedQuotation, CancellationToken cancellationToken)
        {
            if (arrivedQuotation._ownerId == _id || arrivedQuotation._isExecuted)
            {
                return;
            }

            var myOffer = _brokerRepository.FindOffer(arrivedQuotation);

            if (myOffer is null)
            {
                return;
            }

            arrivedQuotation._isExecuted = true;
            Notifications.NotifyTransaction(myOffer, arrivedQuotation);

            _brokerRepository.Remove(myOffer);
        }
示例#3
0
        public List <StockQuotation> GetData(int start, int limit)
        {
            List <StockQuotation> data = new List <StockQuotation>();

            Random   randow = new Random();
            DateTime now    = DateTime.Now;

            for (int i = start + 1; i <= start + limit; i++)
            {
                StockQuotation qoute = new StockQuotation()
                {
                    Company    = "Company " + i,
                    Price      = randow.Next(0, 200),
                    LastUpdate = now
                };

                data.Add(qoute);
            }

            return(data);
        }
 public ActionResult GetStockQuotations(int start, int limit)
 {
     return(this.Store(StockQuotation.GetStockQuotations(start, limit), 5000));
 }