public ActionResult <Customer> Get(int id)
        {
            Customer customer = _repository.Get(id);

            if (customer == null)
            {
                return(NotFound(NotFoundResponse.Create <Customer>(id)));
            }

            return(Ok(customer));
        }
        public ActionResult <Order> Get(int id)
        {
            Order order = _repository.Get(id);

            if (order == null)
            {
                return(NotFound(NotFoundResponse.Create <Order>(id)));
            }

            return(Ok(order));
        }
        public async Task <ActionResult <Customer> > Delete(int id)
        {
            Customer customer = _repository.Get(id);

            if (customer == null)
            {
                return(NotFound(NotFoundResponse.Create <Customer>(id, CrudAction.Delete)));
            }

            _repository.Delete(id);

            await _deletedMessagePublisher.Value.Send(customer);

            return(customer);
        }
Beispiel #4
0
        public ActionResult <CustomerOrderOutput> Get(int customerId)
        {
            Customer customer = _customerRepository.Get(customerId);

            if (customer == null)
            {
                return(NotFound(NotFoundResponse.Create <Customer>(customerId)));
            }

            IEnumerable <Order> orders = _orderRepository.GetForCustomer(customerId);

            CustomerOrderOutput output = new ()
            {
                Customer = customer,
                Orders   = orders
            };

            return(Ok(output));
        }
    }