public IActionResult Pay(int id) { var order = repository.Get(id); if (order == null) { return(NotFound()); } if (order.Status == Order.OrderStatus.paid) { return(StatusCode(500, "Already paid")); } try { messagePublisher.PublishCustomerStatusChangedMessage( order.customerId, order.TotalPrice, "paid"); order.Status = Order.OrderStatus.paid; repository.Edit(order); return(new NoContentResult()); } catch { return(StatusCode(500, "An error happened. Try again.")); } }