Exemplo n.º 1
0
        public async Task <ActionResult> Index(Order order)
        {
            //Request is an extension method in the NServiceBus.Callbacks NuGet package
            //You also need to assign a unique id to the endpoint
            var priceResponse = await endpoint.Request <PriceResponse>(new PriceRequest { Weight = order.Weight });

            order.Price = priceResponse.Price;
            return(View("Review", order));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Confirm(Order order)
        {
            await endpoint.Send("FireOnWheels.Order", new ProcessOrderCommand
            {
                AddressFrom = order.AddressFrom,
                AddressTo   = order.AddressTo,
                Price       = order.Price,
                Weight      = order.Weight
            }).ConfigureAwait(false);

            return(View());
        }
Exemplo n.º 3
0
        public ActionResult Confirm(Order order)
        {
            ServiceBus.Bus.Send("fireonwheels.order", new ProcessOrderCommand
            {
                AddressFrom = order.AddressFrom,
                AddressTo   = order.AddressTo,
                Price       = order.Price,
                Weight      = order.Weight
            });

            return(View());
        }
Exemplo n.º 4
0
        public ActionResult Confirm(Order order)
        {
            ServiceBus.Bus.Send(new ProcessOrderCommand
            {
                OrderId     = Guid.NewGuid(),
                AddressFrom = order.AddressFrom,
                AddressTo   = order.AddressTo,
                Price       = order.Price,
                Weight      = order.Weight
            });

            return(View());
        }
Exemplo n.º 5
0
        public async Task <ActionResult> Index(Order order)
        {
            var options = new SendOptions();

            options.SetDestination("FireOnWheels.Order");

            //Request is an extension method in the NServiceBus.Callbacks NuGet package
            //You also need to assign a unique id to the endpoint
            var priceResponse = await endpoint.Request <PriceResponse>(new PriceRequest { Weight = order.Weight }, options);

            order.Price = priceResponse.Price;
            return(View("Review", order));
        }
Exemplo n.º 6
0
        public async Task <ActionResult> Confirm(Order order)
        {
            await endpoint.Send(new ProcessOrderCommand
            {
                OrderId     = Guid.NewGuid(),
                AddressFrom = order.AddressFrom,
                AddressTo   = order.AddressTo,
                Price       = order.Price,
                Weight      = order.Weight
            }).ConfigureAwait(false);

            return(View());
        }
Exemplo n.º 7
0
        public ActionResult Index(Order order)
        {
            var callback = ServiceBus.Bus.Send(new PriceRequest {
                Weight = order.Weight
            })
                           .Register(result =>
            {
                var localResult = (CompletionResult)result.AsyncState;
                var reply       = (PriceResponse)localResult.Messages[0];
                order.Price     = reply.Price;
            }, null);

            callback.AsyncWaitHandle.WaitOne();

            return(View("Review", order));
        }
Exemplo n.º 8
0
 public ActionResult Index(Order order)
 {
     order.Price = PriceCalculator.GetPrice(order);
     return(View("Review", order));
 }