public HttpResponseMessage Get()
        {
            int top;
            int clientId;
            var parameters = System.Web.HttpUtility.ParseQueryString(Request.RequestUri.Query);
            IEnumerable <string> result = new List <string>();

            if (!parameters.AllKeys.Any(k => k == "clientId") && !parameters.AllKeys.Any(k => k == "top"))
            {
                return(Request.CreateResponse(new ArgumentException($"{Request.RequestUri.Query} does not contains appropriate command")));
            }

            if (!int.TryParse(parameters.Get("clientId"), out clientId))
            {
                return(Request.CreateResponse(new ArgumentException($"{Request.RequestUri.Query} clientId should be an integer.")));
            }

            if (!int.TryParse(parameters.Get("top"), out top))
            {
                return(Request.CreateResponse(new ArgumentException($"{Request.RequestUri.Query} top should be an integer.")));
            }

            var clientShares = transactionsService.GetAllTransactions().Where(x => x.BuyerID == clientId).OrderBy(x => x.Date).Take(top);

            return(Request.CreateResponse(HttpStatusCode.OK, clientShares));
        }
示例#2
0
        public void Execute()
        {
            this.logger.RunWithExceptionLogging(() =>
            {
                this.tradeTable.Draw(transactService.GetAllTransactions());
            });

            this.logger.WriteMessage("Got all transactions from transaction base.");
        }
示例#3
0
        public async Task <IActionResult> GetAllTransactions([FromQuery] TransactionsParameter transactionsParameter)
        {
            var result = await transactionsService.GetAllTransactions(transactionsParameter);

            return(StatusCode((int)result.Code, result.Value));
        }