public void AddCustomer(Customer customer)
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Got message: {0}", customer.Id);
            Console.WriteLine("First Name: {0}", customer.Name.FirstName);
            Console.WriteLine("First Last Name: {0}", customer.Name.LastName);
            Console.ResetColor();

            var messageDescription = MessageDescriptionFormat.Json;
            var translationFileUri = "./Translations/Json/JavascriptTranslations/CustomerToCustomerTranslation.js";
            var translationReturnType = typeof(Customer);
            var configurationJsonUri = "./ServiceConfigurations/CustomerConfiguration.json";

            // Wrap the message
            var wrappedMessage = MessageDescription.Create(
                customer,
                messageDescription,
                translationFileUri,
                translationReturnType);

            // Get Params
            var @params = translationService.GetMessageParts(wrappedMessage);
            // Call the translation on customer
            var translated = translationService.Translate<Customer, Customer>(wrappedMessage);            

            // Known the appropriate Adaptor
            var adapter = new RestAdapter();
            adapter.Initialize(configurationJsonUri);

            // Send to the Adaptor
            adapter.SendAsync(translated);
        }
Esempio n. 2
0
        public CustomerModule() : base("/customer")
        {
            Post["/"] = _ =>
            {
                var customer = this.Bind<Customer>();

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Recieved Message: {0}", customer.Id);
                Console.WriteLine("First Name: {0}", customer.Name.FirstName);
                Console.WriteLine("First Last Name: {0}", customer.Name.LastName);
                Console.ResetColor();

                return "Success!";
            };

            Get["/"] = _ =>
            {
                var id = Request.Query.Id;

                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Recieved Message: {0}", id);
                Console.ResetColor();

                var customer = new Customer()
                {
                    Id = id,
                    Name = new Name()
                    {
                        FirstName = "John",
                        MiddleName = "Jane",
                        LastName = "Doe"
                    },
                    Address = new Address()
                    {
                        AddressLine1 = "5 City Street",
                        AddressLine2 = "",
                        City = "Ottawa",
                        ProvinceState = "ON",
                        Country = "CA",
                        PostalZipCode = "5A5A5A"
                    }
                };

                return Response.AsJson(customer);
            };
        }