示例#1
0
        public HttpResponseMessage GetTrade(int tID)
        {
            TradeInfo objTradeInfo = new TradeInfo();
            TransactionalInformation transaction              = new TransactionalInformation();
            TradesBusinessService    tradesBusinessService    = new TradesBusinessService(tradesDataService);
            ExchangeBusinessService  exchangesBusinessService = new ExchangeBusinessService(exchangesDataService);
            MarketBusinessService    marketsBusinessService   = new MarketBusinessService(marketsDataService);

            objTradeInfo.IsAuthenicated = true;

            ttrade trade = tradesBusinessService.GetTrade(tID, out transaction);

            List <texchanx> exchanges = exchangesBusinessService.GetExchanges(out transaction);
            List <tmarket>  markets   = marketsBusinessService.GetMarkets(out transaction);

            objTradeInfo.Trade          = trade;
            objTradeInfo.Exchanges      = exchanges;
            objTradeInfo.Markets        = markets;
            objTradeInfo.IsAuthenicated = true;
            objTradeInfo.ReturnStatus   = transaction.ReturnStatus;
            objTradeInfo.ReturnMessage  = transaction.ReturnMessage;

            if (transaction.ReturnStatus == true)
            {
                var response = Request.CreateResponse <TradeInfo>(HttpStatusCode.OK, objTradeInfo);
                return(response);
            }

            var badResponse = Request.CreateResponse <TradeInfo>(HttpStatusCode.BadRequest, objTradeInfo);

            return(badResponse);
        }
示例#2
0
        public HttpResponseMessage UpdateTrade(HttpRequestMessage request, [FromBody] TradeInfo objTradeInfo)
        {
            TransactionalInformation transaction = new TransactionalInformation();
            TradesBusinessService    tradesBusinessService;

            objTradeInfo.IsAuthenicated = true;

            tradesBusinessService = new TradesBusinessService(tradesDataService);

            ttrade trade = tradesBusinessService.UpdateTrade(
                objTradeInfo.TID,
                objTradeInfo.ACCOUNTID,
                objTradeInfo.EXCHANGE,
                objTradeInfo.MASTERID,
                objTradeInfo.TRADEGROUPID,
                objTradeInfo.TRADINGACTION,
                objTradeInfo.TRADINGPAIR,
                objTradeInfo.TRADINGPRICE,
                objTradeInfo.ACTUALRATE,
                objTradeInfo.TRADINGQTY,
                objTradeInfo.TOTAL,
                objTradeInfo.ORDERID,
                objTradeInfo.ORDERSTATUS,
                objTradeInfo.DATETIME,
                objTradeInfo.ORDERRESULT,
                objTradeInfo.RETRYIFCANCELED,
                objTradeInfo.USEEXCHANGEPRICE,
                objTradeInfo.ERRORRESULT,
                out transaction);

            if (transaction.ReturnStatus == false)
            {
                objTradeInfo.ReturnMessage    = transaction.ReturnMessage;
                objTradeInfo.ReturnStatus     = transaction.ReturnStatus;
                objTradeInfo.ValidationErrors = transaction.ValidationErrors;
                var badResponse = Request.CreateResponse <TradeInfo>(HttpStatusCode.BadRequest, objTradeInfo);
                return(badResponse);
            }

            objTradeInfo.ReturnStatus  = transaction.ReturnStatus;
            objTradeInfo.ReturnMessage = transaction.ReturnMessage;
            objTradeInfo.Trade         = trade;

            var response = Request.CreateResponse <TradeInfo>(HttpStatusCode.OK, objTradeInfo);

            return(response);
        }
示例#3
0
        public HttpResponseMessage GetTrades([FromBody] TradeInfo objTradeInfo)
        {
            if (objTradeInfo.ORDERID == null)
            {
                objTradeInfo.ORDERID = string.Empty;
            }
            if (objTradeInfo.ORDERSTATUS == null)
            {
                objTradeInfo.ORDERSTATUS = string.Empty;
            }
            if (objTradeInfo.SortDirection == null)
            {
                objTradeInfo.SortDirection = string.Empty;
            }
            if (objTradeInfo.SortExpression == null)
            {
                objTradeInfo.SortExpression = string.Empty;
            }

            TransactionalInformation transaction = new TransactionalInformation();
            TradesBusinessService    tradesBusinessService;

            objTradeInfo.IsAuthenicated = true;

            DataGridPagingInformation paging = new DataGridPagingInformation();

            paging.CurrentPageNumber = objTradeInfo.CurrentPageNumber;
            paging.PageSize          = objTradeInfo.PageSize;
            paging.SortExpression    = objTradeInfo.SortExpression;
            paging.SortDirection     = objTradeInfo.SortDirection;

            if (paging.SortDirection == "")
            {
                paging.SortDirection = "DESC";
            }
            if (paging.SortExpression == "")
            {
                paging.SortExpression = "FirstName";
            }

            tradesBusinessService = new TradesBusinessService(tradesDataService);

            List <ttrade> trades = tradesBusinessService.TradeInquiry(objTradeInfo.ORDERID, objTradeInfo.ORDERSTATUS, paging, out transaction);

            objTradeInfo.Trades        = trades;
            objTradeInfo.ReturnStatus  = transaction.ReturnStatus;
            objTradeInfo.ReturnMessage = transaction.ReturnMessage;
            objTradeInfo.TotalPages    = transaction.TotalPages;
            objTradeInfo.TotalRows     = transaction.TotalRows;
            objTradeInfo.PageSize      = paging.PageSize;

            if (transaction.ReturnStatus == true)
            {
                var response = Request.CreateResponse <TradeInfo>(HttpStatusCode.OK, objTradeInfo);
                return(response);
            }

            var badResponse = Request.CreateResponse <TradeInfo>(HttpStatusCode.BadRequest, objTradeInfo);

            return(badResponse);
        }