Ejemplo n.º 1
0
        private async void OrderEvent_Received(object sender, BasicDeliverEventArgs e)
        {
            Console.WriteLine($"A message of type {e.BasicProperties?.Type} has been received received");

            try
            {
                switch (e?.BasicProperties.Type)
                {
                case nameof(DeliveryPickedUpEvent):
                    await HandleStatusChangedEvent(MessageSerializationHelper.DeserializeObjectFromBin <DeliveryPickedUpEvent>(e.Body).idOrder, DTO.Orders.Status.Delivering);

                    break;

                case nameof(DeliveryCompletedEvent):
                    await HandleStatusChangedEvent(MessageSerializationHelper.DeserializeObjectFromBin <DeliveryCompletedEvent>(e.Body).idOrder, DTO.Orders.Status.Completed);

                    break;

                default:
                    throw new NotImplementedException($"Event not supported: {e.BasicProperties?.Type}");
                }
            }
            catch (Exception ex)
            {
                _logger.Log(ex.Message, Microsoft.Extensions.Logging.LogLevel.Error, System.Net.HttpStatusCode.InternalServerError, $"{nameof(OrdersEventManager)} - OrderEvent_Received");
                throw ex;
            }
        }
Ejemplo n.º 2
0
        private async void Restaurant_Received(object sender, BasicDeliverEventArgs e)
        {
            Console.WriteLine($"A message of type {e.BasicProperties?.Type} has been received received");

            switch (e?.BasicProperties.Type)
            {
            case nameof(RatingChangedEvent):
                await HandleRatingEvent(MessageSerializationHelper.DeserializeObjectFromBin <RatingChangedEvent>(e.Body));

                break;

            default:
                throw new NotImplementedException($"Event not supported: {e.BasicProperties?.Type}");
            }
        }
Ejemplo n.º 3
0
        private void OrderEvent_Received(object sender, BasicDeliverEventArgs e)
        {
            switch (e?.BasicProperties.Type)
            {
            case nameof(DeliveryPickedUpEvent):
                HandleStatusChangedEvent(MessageSerializationHelper.DeserializeObjectFromBin <DeliveryPickedUpEvent>(e.Body).idOrder, DTO.Status.Delivering);
                break;

            case nameof(DeliveryCompletedEvent):
                HandleStatusChangedEvent(MessageSerializationHelper.DeserializeObjectFromBin <DeliveryCompletedEvent>(e.Body).idOrder, DTO.Status.Completed);
                break;

            default:
                throw new NotImplementedException($"Event not supported: {e.BasicProperties?.Type}");
            }
        }
Ejemplo n.º 4
0
        private async void DeliveryEvent_Received(object sender, BasicDeliverEventArgs e)
        {
            switch (e?.BasicProperties.Type)
            {
            case nameof(OrderAcceptedEvent):
                HandleOrderAcceptedEvent(MessageSerializationHelper.DeserializeObjectFromBin <OrderAcceptedEvent>(e.Body));
                break;

            case nameof(RiderRatingChangedEvent):
                await HandleRiderRatingChangedEvent(MessageSerializationHelper.DeserializeObjectFromBin <RiderRatingChangedEvent>(e.Body));

                break;

            default:
                throw new NotImplementedException($"Event not supported: {e.BasicProperties?.Type}");
            }
        }
Ejemplo n.º 5
0
        private void RestaurantsEvents_Received(object sender, BasicDeliverEventArgs e)
        {
            Console.WriteLine($"Message of type {e.BasicProperties?.Type} received from RestaurantsService");

            switch (e?.BasicProperties.Type)
            {
            case nameof(PriceChangedEvent):
                HandlePriceChangedEvent(MessageSerializationHelper.DeserializeObjectFromBin <PriceChangedEvent>(e.Body));
                break;

            case nameof(ProductAvailabilityChangedEvent):
                HandleProductAvailabilityChangedEvent(MessageSerializationHelper.DeserializeObjectFromBin <ProductAvailabilityChangedEvent>(e.Body));
                break;

            default:
                throw new NotImplementedException($"Event not supported: {e.BasicProperties?.Type}");
            }
        }