Beispiel #1
0
        public IActionResult GetTransactionsByMerchant(int merchantId)
        {
            if (!_merchantRepository.MerchantExists(merchantId))
            {
                return(NotFound());
            }

            var transactions = _merchantRepository.GeTransactionsByMerchant(merchantId);

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var transactionsDto = new List <TransactionDto>();

            foreach (var transaction in transactions)
            {
                transactionsDto.Add(new TransactionDto()
                {
                    Id       = transaction.Id,
                    Name     = transaction.Name,
                    Price    = transaction.Price,
                    DateTime = transaction.DateTime
                });
            }

            return(Ok(transactionsDto));
        }