Beispiel #1
0
        protected void btnGetCustomer_Click(object sender, EventArgs e)
        {
            ServiceReference1.IHelloService client = new ServiceReference1.HelloServiceClient("wsHttpBinding_IHelloService" /*"BasicHttpBinding_IHelloService"*/);

            ServiceReference1.CustomerRequest request = new ServiceReference1.CustomerRequest();
            request.LicenseKey       = "SuperSecret123";
            request.CustomerLastName = txtCustomLastName.Text;

            ServiceReference1.CustomerInfo customer = client.GetCustomer(request);

            if (customer.FirstName != null)
            {
                txtCustomFirstName.Text = customer.FirstName;
                txtCustomLastName.Text  = customer.LastName;
                txtPhone.Text           = customer.Phone;
                txtEmail.Text           = customer.Email;

                lblCustomer.Text = "Customer retrieved";
            }
            else
            {
                txtCustomFirstName.Text = "-";
                txtCustomLastName.Text  = "-";
                txtEmail.Text           = "-";
                txtPhone.Text           = "-";

                lblCustomer.Text = "Couldn't find customer";
            }
        }
Beispiel #2
0
        protected void btnSaveCustomer_Click(object sender, EventArgs e)
        {
            ServiceReference1.IHelloService client   = new ServiceReference1.HelloServiceClient("wsHttpBinding_IHelloService");
            ServiceReference1.CustomerInfo  customer = new ServiceReference1.CustomerInfo();


            customer.FirstName = txtCustomFirstName.Text;
            customer.LastName  = txtCustomLastName.Text;
            customer.Phone     = txtPhone.Text;
            customer.Email     = txtEmail.Text;

            client.SaveCustomer(customer);
            lblCustomer.Text = "Customer saved";
        }
Beispiel #3
0
        protected void btnSaveBook_Click(object sender, EventArgs e)
        {
            ServiceReference1.IHelloService    client      = new ServiceReference1.HelloServiceClient("wsHttpBinding_IHelloService");
            ServiceReference1.Car              car         = client.GetCarByReg(txtAvailableRegCar.Text);
            ServiceReference1.ReservationInfo1 reservation = new ServiceReference1.ReservationInfo1();
            ServiceReference1.CustomerInfo     customer    = new ServiceReference1.CustomerInfo();

            if (carsRegnum.Contains(car._Regnumber))
            {
                customer.FirstName = txtFirstName.Text;
                customer.LastName  = txtLastName.Text;
                customer.Phone     = txtPhonenumber.Text;
                customer.Email     = txtEmailAddress.Text;

                try
                {
                    client.SaveCustomer(customer);
                }
                catch (FaultException faultException)
                {
                    lblReservationResult.Text = faultException.Message;
                }

                reservation.Brand     = car._Brand;
                reservation.Model     = car._Model;
                reservation.Regnumber = car._Regnumber;
                reservation.Year      = car._Year;
                reservation.StartDate = Convert.ToDateTime(txtBookStartDate.Text);
                reservation.EndDate   = Convert.ToDateTime(txtBookuntil.Text);
                reservation.LastName  = customer.LastName;
                reservation.Returned  = false;


                try
                {
                    client.AddReservation(reservation);
                    lblReservationResult.Text = "Reservation successfully saved";
                }
                catch (FaultException faultException)
                {
                    lblReservationResult.Text = faultException.Message;
                }
            }
            else
            {
                lblReservationResult.Text = "Car is not available during the period of choice";
            }
        }