public GetProductsByCategoryResponse GetProductsByCategory(GetProductsByCategoryRequest request)
        {
            Expression <Func <Product, bool> > productQuery          = ProductSearchRequestQueryGenerator.CreateQueryFor(request);
            IEnumerable <Product>         productsMatchingRefinement = GetAllProductsMatchingQueryAndSort(request, productQuery);
            GetProductsByCategoryResponse response = CreateProductSearchResultFrom(productsMatchingRefinement, request);

            response.SelectedCategoryName = _categoryRepository.FindBy(request.CategoryId).Name;

            return(response);
        }
        public async Task <GetPaymentResult> Handle(GetPaymentQuery query, CancellationToken cancellationToken)
        {
            var payment = await _paymentRepository.FindBy(Guid.Parse(query.PaymentId));

            if (payment == null)
            {
                _logger.Error($"There is no payment with id: {query.PaymentId}");
                return(new ErrorResult($"There is no payment with id: {query.PaymentId}"));
            }

            var cardNumber = _cryptoService.Decrypt(payment.CardNumber, payment.EncriptionKey);

            return(new SuccessResult
            {
                CardNumber = cardNumber.Mask(),
                Amount = payment.Amount,
                PaymentDate = payment.CreatedDate,
                PaymentStatus = payment.PaymentStatus,
                Currency = payment.Currency
            });
        }
 public TEntity FindBy(ISpecification <TEntity> spec)
 {
     return(_readOnlyRepository.FindBy(spec));
 }