Exemple #1
0
        //Update Guest Details
        async void saveButton(object sender, EventArgs e)
        {
            string validation = FieldValidation.guestSaveDetailsValidation(IdentificationMethod, IdentificationMethodNumber.Text, GuestFisrtName.Text, GuestLastName.Text, DateOfBirth, GuestContact.Text, GuestEmail.Text, City.Text, Street.Text);

            if (validation != "")
            {
                await DisplayAlert("Warning!", validation, "Ok");
            }
            else
            {
                DateTime date = DateOfBirth.Date;

                DateTime dateOfEx = PassportExpiry.Date;

                //Page loading indicator
                pageLoading();

                //Pass values to payload
                StatusChange statusChange = new StatusChange(Constants._hotel_code, Constants._reservation_id, guestIdentification, IdentificationMethodNumber.Text, guestNumber.Text, guestSalutation, GuestFisrtName.Text, GuestLastName.Text, guestGender, GuestEmail.Text, GuestContact.Text, HouseNumber.Text, Street.Text, City.Text, guestCountry, guestNationality, guestLanguage, date.ToString("s"), dateOfEx.ToString("s"));
                //PPExpiryDate expiryDateChange = new PPExpiryDate(Constants._hotel_code, Constants._reservation_id, guestNumber.Text, guestSalutation, GuestFisrtName.Text, GuestLastName.Text, IdentificationMethodNumber.Text ,dateOfEx.ToString("s"),guestIdentification,guestCountry,guestLanguage);

                //Data Posting source
                //PostServiceManager postServiceManager = new PostServiceManager();
                GuestPostManager guestPostManager = new GuestPostManager();

                string result = await guestPostManager.CreateUpdateGuest(statusChange);

                //String result = await postServiceManager.StatusChangeAsync(statusChange);
                //String result2 = await postServiceManager.SavePPExpiryAsync(expiryDateChange);


                if (result != "Reservation is locked" || result.Contains("Updated Successfully"))
                {
                    //Updateing guest details object
                    var obj = guestdetails.FirstOrDefault(x => x.guestNumber == Int32.Parse(guestNumber.Text));
                    obj.guestNumber          = Int32.Parse(guestNumber.Text);
                    obj.identificationMethod = guestIdentification;
                    obj.passportIdNumber     = IdentificationMethodNumber.Text;
                    obj.salutation           = guestSalutation;
                    obj.guestName            = GuestFisrtName.Text + " " + GuestLastName.Text;
                    obj.guestFirstName       = GuestFisrtName.Text;
                    obj.guestLastName        = GuestLastName.Text;
                    obj.gender          = guestGender;
                    obj.email           = GuestEmail.Text;
                    obj.contactNumber   = GuestContact.Text;
                    obj.houseNumber     = HouseNumber.Text;
                    obj.street          = Street.Text;
                    obj.city            = City.Text;
                    obj.nationality     = guestNationality;
                    obj.country         = guestCountry;
                    obj.language        = guestLanguage;
                    obj.guestCode       = guestCodeFromSearch;
                    obj.dateOfBirth     = date.ToString("s");
                    obj.dateOfExpiry    = dateOfEx.ToString("s");
                    obj.noOfVisitsHotel = Visitperhotel;
                    obj.noOfVisits      = Totalvisit;
                    obj.revenueTotal    = RevenueTotal;
                    obj.revenueRoom     = RevenueRoom;
                    obj.reveneuFB       = RevenueFnb;
                    obj.revenueOther    = RevenueOther;

                    var nameToCountry = CountryDictionary.listOfCountrie();
                    if (guestCountry != "" || guestCountry != "")
                    {
                        //Item Value in dictionary
                        string name = nameToCountry.FirstOrDefault(x => x.Value == guestCountry).Key;
                        obj.countryKeyValue = name;
                    }

                    Constants._guestNumber = "";
                    Constants._guestNumber = guestNumber.Text;


                    if (Constants.PassportCopy != null)
                    {
                        await FTPService.UploadPassportCopy(Constants.PassportCopy, GuestFisrtName.Text);
                    }

                    stopPageLoading();

                    //Guest details updateindicator, Reload content page
                    MessagingCenter.Send <GuestEdit, List <guestDetails> >(this, Constants._guestEdited, guestdetails);
                    await DisplayAlert("Message", result, "OK");

                    ////Logger
                    //new APILogger().Logger("Guest Payload :" + JsonConvert.SerializeObject(statusChange));
                    //new APILogger().Logger("Guest Save Status :" + result);

                    //Close this content page
                    this.Navigation.RemovePage(this);
                }
                else
                {
                    stopPageLoading();
                    await DisplayAlert("Message", result, "OK");
                }
            }
        }