Exemple #1
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);
        }