public async Task <IActionResult> GetAll()
        {
            try
            {
                var customers = await _customerRepo.GetAsync();

                return(Ok(_mapper.Map <IEnumerable <Customer>, IEnumerable <CustomerDto> >(customers)));
            }
            catch (Exception e)
            {
                _log.LogError($"error getting customers {e}");
            }

            return(BadRequest());
        }
示例#2
0
        public async Task <Customer> GetCustomerDetailById(int id)
        {
            var customer = await _customerRepo.GetAsync(id);

            if (customer == null)
            {
                throw new NotFoundException("Customer Not found");
            }

            return(customer);
        }