示例#1
0
        public Response CreateCustomer(Dictionary <string, object> parameters)
        {
            try
            {
                CustomerDetailsRequest cusReq = new CustomerDetailsRequest();
                var sess    = new SessionRequest();
                var vehicle = new VehicleRequest();
                var client  = new ClientRequest();
                sess.Username                     = (String)parameters["username"];
                sess.AuthenticationKey            = (String)parameters["AuthenticationKey"];
                client.FirstName                  = (String)parameters["firstname"];
                client.Surname                    = (String)parameters["surname"];
                client.Title                      = (String)parameters["title"];
                client.HouseNumber                = (String)parameters["housenumber"];
                client.Address                    = (String)parameters["address"];
                client.Postcode                   = (String)parameters["postcode"];
                client.Email                      = (String)parameters["email"];
                client.Telephone                  = (String)parameters["telephone"];
                client.Contact_by_email           = (bool)parameters["contact_by_email"];
                client.Contact_by_phone           = (bool)parameters["contact_by_phone"];
                client.Contact_by_post            = (bool)parameters["contact_by_post"];
                client.Contact_by_text            = (bool)parameters["contact_by_text"];
                client.DateOfBirth                = (DateTime)parameters["dateofbirth"];
                client.Mobile                     = (String)parameters["mobile"];
                client.IsCompany                  = (bool)parameters["iscompany"];
                sess.DealerFittedAccessoriesValue = (decimal)parameters["dealerfittedaccessories"];
                vehicle.Make                      = (String)parameters["make"];
                vehicle.Model                     = (String)parameters["model"];
                vehicle.Registration              = (String)parameters["registration"];
                vehicle.Price                     = (decimal)parameters["price"];
                vehicle.Mileage                   = (int)parameters["mileage"];
                vehicle.DateRegistered            = (DateTime)parameters["dateregistered"];
                vehicle.EngineSize                = (int)parameters["enginesize"];
                vehicle.MOTDate                   = (DateTime)parameters["motdate"];
                vehicle.Fuel                      = (String)parameters["fuel"];
                vehicle.NewVehicle                = (bool)parameters["newvehicle"];
                vehicle.Motorcycle                = (bool)parameters["motorcycle"];
                vehicle.AntilockBrakes            = (bool)parameters["antilockbrakes"];
                vehicle.AirConditioner            = (bool)parameters["airconditioner"];
                vehicle.FourWheelDrive            = (bool)parameters["fourwheeldrive"];
                vehicle.Turbo                     = (bool)parameters["turbo"];
                vehicle.SpecialCategory           = (bool)parameters["specialcategory"];
                vehicle.Automatic                 = (bool)parameters["automatic"];

                cusReq.Session = sess;
                cusReq.Client  = client;
                cusReq.Vehicle = vehicle;
                var response = insuranceWebService.CreateCustomer(cusReq);
                return(MethodRespToObject(response));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.InnerException.Message);
                return(null);
            }
        }
示例#2
0
        static void aMain(string[] args)
        {
            InsuranceWebService insuranceWebService = new InsuranceWebService();
            var cusRequest = new CustomerDetailsRequest();
            var mySession  = new SessionRequest();
            var myClient   = new ClientRequest();
            var myVehicle  = new VehicleRequest();


            //Username and Authentication key always needed
            mySession.Username          = "";
            mySession.AuthenticationKey = "";

            /*
             * For Create Customers not all fields are required
             * Fields can be left as empty strings e.g. ""
             */

            //Optional
            mySession.DeliveryDate = new DateTime();
            mySession.DealerFittedAccessoriesValue = 0;
            //END Optional
            myClient.FirstName        = "";
            myClient.Surname          = "";
            myClient.Title            = "";
            myClient.HouseNumber      = "";
            myClient.Address          = "";
            myClient.Postcode         = "";
            myClient.Email            = "";
            myClient.Telephone        = "";
            myClient.Contact_by_email = false;
            myClient.Contact_by_phone = false;
            myClient.Contact_by_post  = false;
            myClient.Contact_by_text  = false;

            //Optional assignment; does not necessarily need to be assigned
            myClient.DateOfBirth = new DateTime();
            //END Optional

            myClient.Mobile    = "";
            myClient.IsCompany = false;

            myVehicle.Make         = "";
            myVehicle.Model        = "";
            myVehicle.Registration = "";

            //Optional
            myVehicle.Price          = 0;
            myVehicle.Mileage        = 0;
            myVehicle.DateRegistered = new DateTime();
            myVehicle.EngineSize     = 0;
            myVehicle.MOTDate        = new DateTime();
            //END Optional

            myVehicle.Fuel            = "";
            myVehicle.NewVehicle      = false;
            myVehicle.Motorcycle      = false;
            myVehicle.AntilockBrakes  = false;
            myVehicle.AirConditioner  = false;
            myVehicle.FourWheelDrive  = false;
            myVehicle.Turbo           = false;
            myVehicle.SpecialCategory = false;
            myVehicle.Automatic       = false;
            cusRequest.Session        = mySession;
            cusRequest.Vehicle        = myVehicle;
            cusRequest.Client         = myClient;



            var response = insuranceWebService.CreateCustomer(cusRequest);

            if (response.Success)
            {
                Console.WriteLine("Success");
            }
            else
            {
                Console.WriteLine("Fail");
            }
            Console.ReadKey();
        }