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)); }
public void Execute() { this.logger.RunWithExceptionLogging(() => { this.tradeTable.Draw(transactService.GetAllTransactions()); }); this.logger.WriteMessage("Got all transactions from transaction base."); }
public async Task <IActionResult> GetAllTransactions([FromQuery] TransactionsParameter transactionsParameter) { var result = await transactionsService.GetAllTransactions(transactionsParameter); return(StatusCode((int)result.Code, result.Value)); }