public async Task <IActionResult> Get([FromQuery] GetCardListRequest request)
        {
            var query = new GetCardListQuery()
            {
                CardHolder = request.CardHolder,
                ChargeDate = request.ChargeDate,
                Number     = request.Number,
                Limit      = request.Limit,
                Offset     = request.Offset
            };

            var result = await queryDispatcher.ExecuteAsync(query);

            if (!result.Any())
            {
                return(NotFound(query));
            }

            var respose = result.Select(x => new GetCardListResponse()
            {
                Id                       = x.Id,
                Number                   = x.Number,
                CardHolder               = x.CardHolder,
                ExpirationDate           = x.ExpirationDate,
                HighestTransactionAmount = x.HighestTransactionAmount,
                HighestTransactionId     = x.HighestTransactionId
            });

            return(Ok(respose));
        }
        public async Task <CalcData[]> GetCalcData([FromRoute] string sensorId = "temperature")
        {
            var query = new GetAggregatedDataQuery
            {
                SensorId = sensorId,
                Limit    = batchSettings.AggregationsPageLimit
            };

            return(await queryDispatcher.ExecuteAsync(query));
        }
Exemple #3
0
        public async Task <IActionResult> Get()
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }
                var query  = new GetAvailableTableQuery();
                var result = await queryDispatcher.ExecuteAsync(query);

                if (!result.Tables.Any())
                {
                    return(NotFound(query));
                }

                var response = mapper.Map <List <TableDto> >(result.Tables);

                return(Ok(response));
            }
            catch (Exception ex)
            {
                logger?.LogError($"Exception caught {nameof(TablesController)}");
                throw ex;
            }
        }
Exemple #4
0
        public async Task <IActionResult> Get([FromQuery] GetTransactionsRequest request)
        {
            var query = new GetTransactionListQuery()
            {
                BetweenAmount = request.BetweenAmount,
                CardHolder    = request.CardHolder,
                CardNumber    = request.CardNumber,
                ChargeDate    = request.ChargeDate,
                Limit         = request.Limit,
                Offset        = request.Offset
            };

            var result = await queryDispatcher.ExecuteAsync(query);

            if (!result.Any())
            {
                return(NotFound(query));
            }

            var response = result.Select(x => new GetTransactionsResponse()
            {
                Amount       = x.Amount,
                CardHolder   = x.CardHolder,
                CardNumber   = x.CardNumber,
                ChargeDate   = x.ChargeDate,
                CurrencyCode = x.CurrencyCode,
                UniqueId     = x.UniqueId
            });

            return(Ok(response));
        }
        public async Task <ActionResult <IEnumerable <UserLocationRequestModel> > > GetByUserId([FromQuery] Guid userId)
        {
            var query          = new GetUserActivityByIdQuery(userId);
            var userActivities = await queryDispatcher.ExecuteAsync <GetUserActivityByIdQuery, IEnumerable <UserActivity> >(query);

            return(new OkObjectResult(userActivities));
        }
Exemple #6
0
        public async Task <ActionResult> Survey([FromRoute] int?id)
        {
            if (!id.HasValue)
            {
                return(BadRequest("id should be specified"));
            }

            var query = new SurveyCreationPageQuery()
            {
                SurveyId = id.Value
            };

            QueryResult <SurveyPageResult> result =
                await _queryDispatcher.ExecuteAsync <SurveyCreationPageQuery, SurveyPageResult>(query);

            if (result.IsSuccess)
            {
                return(Ok(new OkServiceResponse <SurveyPageResult>(result.Value)));
            }
            return(BadRequest(result.Error));
        }
Exemple #7
0
        public async Task <object> DispatchAsync(string commandText)
        {
            var args = commandText.ParseCommandText();

            if (args.Any(a => a == "--help"))
            {
                return(_helpInfoFactory.Create(args));
            }

            var executable = _executableFactory.Create(
                _executableInfoFactory.Create(args));

            var result = executable is ICommand
                ? await _commandDispatcher.ExecuteAsync((ICommand)executable)
                : await _queryDispatcher.ExecuteAsync((IQuery)executable);

            return(result);
        }
Exemple #8
0
        public async Task <IActionResult> GetById(Guid id)
        {
            var query = new GetCardByIdQuery(id);

            var queryResult = await queryDispatcher.ExecuteAsync(query);

            if (queryResult == null)
            {
                return(BadRequest(id));
            }

            var response = new GetCardViewResponse()
            {
                CardHolder     = queryResult.CardHolder,
                ExpirationDate = queryResult.ExpirationDate,
                Id             = queryResult.Id,
                Number         = queryResult.Number
            };

            return(Ok(response));
        }
Exemple #9
0
 public async Task <object> DispatchQueryAsync(IQuery query, ClaimsPrincipal user = null)
 {
     return(await _queryDispatcher.ExecuteAsync(query, user));
 }
 public async Task ExecuteAsync()
 {
     await queryDispatcher.ExecuteAsync(query);
 }