Esempio n. 1
0
        public static async Task <Guid> CheckoutTest(List <CustomerOrderItem> cart)
        {
            // you may want to create a guid and an actor from that guid
            Guid orderId = new Guid();
            ICustomerOrderActor customerOrder = ActorProxy.Create <ICustomerOrderActor>(new ActorId(orderId), applicationName);

            Console.WriteLine("Trying to get initial status of actor...");
            await GetOrderStatus(orderId);

            Console.WriteLine("Theoretically we have created a functioning customerOrder actor");

            // Create actor proxy and send the request
            try
            {
                await customerOrder.SubmitOrderAsync(cart);
            }
            catch (InvalidOperationException ex)
            {
                Console.WriteLine(string.Format("CustomerOrderTestApp Service: Actor rejected {0}: {1}", customerOrder, ex));
                throw;
            }
            catch (Exception ex)
            {
                Console.WriteLine(string.Format("CustomerOrderTestApp: Exception {0}: {1}", customerOrder, ex));
                throw;
            }

            return(orderId);
        }
        public async Task <Guid> PostCheckout(string orderId)
        {
            ServiceEventSource.Current.Message("Now printing cart for POSTCHECKOUT...");

            Guid orderIdGuid          = Guid.Parse(orderId);
            ServiceUriBuilder builder = new ServiceUriBuilder(CustomerOrderServiceName);

            //We create a unique Guid that is associated with a customer order, as well as with the actor that represents that order's state.
            ICustomerOrderActor customerOrder = ActorProxy.Create <ICustomerOrderActor>(new ActorId(orderIdGuid), builder.ToUri());

            try
            {
                await customerOrder.SubmitOrderAsync();

                ServiceEventSource.Current.Message("Customer order submitted successfully. ActorOrderID: {0} created", orderId);
            }
            catch (InvalidOperationException ex)
            {
                ServiceEventSource.Current.Message("Web Service: Actor rejected {0}: {1}", customerOrder, ex);
                throw;
            }
            catch (Exception ex)
            {
                ServiceEventSource.Current.Message("Web Service: Exception {0}: {1}", customerOrder, ex);
                throw;
            }

            return(orderIdGuid);
        }
Esempio n. 3
0
        public async Task <Guid> PostItem(string orderId, CustomerOrderItem item)
        {
            ServiceEventSource.Current.Message("Guid {0}, quantity {1}", item.ItemId.ToString(), item.Quantity.ToString());

            Guid orderIdGuid          = Guid.Parse(orderId);
            ServiceUriBuilder builder = new ServiceUriBuilder(CustomerOrderServiceName);

            //We create a unique Guid that is associated with a customer order, as well as with the actor that represents that order's state.
            ICustomerOrderActor customerOrder = ActorProxy.Create <ICustomerOrderActor>(new ActorId(orderIdGuid), builder.ToUri());

            try
            {
                await customerOrder.AddItemToOrderAsync(item);

                ServiceEventSource.Current.Message("Customer order submitted successfully. ActorOrderID: {0} created", orderId);
            }
            catch (InvalidOperationException ex)
            {
                ServiceEventSource.Current.Message("Web Service: Actor rejected {0}: {1}", customerOrder, ex);
                throw;
            }
            catch (Exception ex)
            {
                ServiceEventSource.Current.Message("Web Service: Exception {0}: {1}", customerOrder, ex);
                throw;
            }

            return(orderIdGuid);
        }
Esempio n. 4
0
        public static async Task GetOrderStatus(Guid customerOrderId)
        {
            ICustomerOrderActor customerOrder = ActorProxy.Create <ICustomerOrderActor>(new ActorId(customerOrderId), applicationName);
            string status = await customerOrder.GetOrderStatusAsStringAsync();

            Console.WriteLine("Order status is: " + status);
            return;
        }
        public Task <string> GetOrderStatus(Guid customerOrderId)
        {
            ServiceUriBuilder   builder       = new ServiceUriBuilder(CustomerOrderServiceName);
            ICustomerOrderActor customerOrder = ActorProxy.Create <ICustomerOrderActor>(new ActorId(customerOrderId), builder.ToUri());

            try
            {
                return(customerOrder.GetOrderStatusAsStringAsync());
            }
            catch (Exception ex)
            {
                ServiceEventSource.Current.Message("Web Service: Exception {0}: {1}", customerOrder, ex);

                throw;
            }
        }