Exemplo n.º 1
0
        public async Task <CollectionResult <CustomerResource> > Get(int?top, int?skip)
        {
            var query     = new GetManyQuery <Customer>(top, skip);
            var customers = await _queryDispatcher.ExecuteAsync <IEnumerable <Customer>, GetManyQuery <Customer> >(query);

            var resources = customers.Select(x => new CustomerResource
            {
                Id   = x.Id,
                Href = HttpContext.GetHref(x.Id)
            }).ToArray();

            return(new CollectionResult <CustomerResource>(resources, query.Skip, query.Top, HttpContext.RequestedUrl()));
        }
Exemplo n.º 2
0
        public async Task <CollectionResult <Order> > Get(int customerId, int?top, int?skip)
        {
            var query  = new GetManyOrdersQuery(customerId, top, skip);
            var orders = await _queryDispatcher.ExecuteAsync <IEnumerable <Order>, GetManyOrdersQuery>(query);

            return(new CollectionResult <Order>(orders, query.Skip, query.Top, HttpContext.RequestedUrl()));
        }
        public async Task <ActionResult <IEnumerable <string> > > Get(CancellationToken cancellationToken)
        {
            _logger.LogInformation("Get values request");
            await Task.Delay(500, cancellationToken);

            return(await _queriesDispatcher.ExecuteAsync(new GetAllValuesQueryCriterion()));
        }
Exemplo n.º 4
0
        public async Task Validate(CreateCustomerCommand command)
        {
            var query = new CheckExistingCustomerByEmailQuery(command.Email);
            var isCustomerAlreadyExist = await _queriesDispatcher.ExecuteAsync <bool, CheckExistingCustomerByEmailQuery>(query);

            if (isCustomerAlreadyExist)
            {
                throw new CustomerWithEmailAlreadyExistException(command.Email);
            }
        }
Exemplo n.º 5
0
 public async Task <IEnumerable <string> > Get()
 {
     _logger.LogInformation("Get values request");
     return(await _queriesDispatcher.ExecuteAsync <string[]>(new GetAllValuesQueryCriterion()));
 }