Exemplo n.º 1
0
        public IActionResult UpdateOrderStatusToComplete(int orderId)
        {
            var checkIncompleteOrder = _ordersRepository.VerifyIncompleteOrderExists(orderId);

            if (checkIncompleteOrder == true)
            {
                var completeOrder = _ordersRepository.CompleteOrder(orderId);
                _rubbishRepository.RubbishNoLongerAvailableAfterOrderComplete(orderId);
                return(Ok(completeOrder));
            }
            else
            {
                var checkForCompletedOrder = _ordersRepository.VerifyCompletedOrderExists(orderId);
                if (checkForCompletedOrder == true)
                {
                    return(Ok("This order has already been completed. No further action necessary."));
                }
                return(NotFound("The requested order does not exist."));
            }
        }