Example #1
0
        public IActionResult GetCustomerInfo(string customerId)
        {
            return(GetHttpResponse(null, () =>
            {
                var customerInfo = _transactionInfoService.GetCustomerTransInfo(customerId, DateTime.Now, DateTime.Now);

                if (customerInfo == null)
                {
                    return StatusCode(StatusCodes.Status500InternalServerError, "Error getting customer information!");
                }

                if (customerInfo.Customer == null)
                {
                    return NotFound(String.Format("Customer {0} not found!", customerId));
                }

                double balance = 0.0;
                foreach (var item in customerInfo.Transactions)
                {
                    balance = balance + item.Amount;
                }

                dynamic result = new
                {
                    customerInfo,
                    balance
                };

                return Ok(result);
            }));
        }
Example #2
0
        public ActionResult Index(CustomerAccount customerAccount)
        {
            var transResponse = transactionInfoService.GetCustomerTransInfo(customerAccount.CustomerId, DateTime.Now, DateTime.Now);

            double balance = 0;

            foreach (var item in transResponse.Transactions)
            {
                balance = balance + item.Amount;
            }

            ViewBag.Balance = balance;

            return(View(transResponse));
        }