コード例 #1
0
        public ActionResult ReservationConfirmation()
        {
            var model = GetLayoutItem <ReservationConfirmation>();
            BlueGreenContext bgcontext = new BlueGreenContext();
            var reservationNo          = Request.QueryString["reservationNo"];

            if (!string.IsNullOrEmpty(reservationNo))
            {
                var reservationType = Request.QueryString["type"];
                model.ActiveReservation = bgcontext.GetActiveReservation(reservationNo, reservationType);

                model.BxgOwner = bgcontext.bxgOwner;
                if (model.ActiveReservation != null)
                {
                    model.taxTotal = ReservationUtils.CalculateReservationTax(model.ActiveReservation);
                    model.ActiveReservation.Amount = model.taxTotal + model.ActiveReservation.AmountDue;
                    model.Guest_NumberOfGuest      = model.ActiveReservation.NumberOfAdults;

                    string specialCharacter = Sitecore.Configuration.Settings.GetSetting("IdentifierForSpecialRequestFromBGO");
                    model.ActiveReservation.Comments = StringUtils.Between(model.ActiveReservation.Comments, specialCharacter, specialCharacter);

                    Session["ActiveReservation"] = model.ActiveReservation;

                    Session["instanceResort"] = ResortUtils.GetResortInfoDetails(FormatUtils.ConvertStringToInt(model.ActiveReservation.ProjectStay), model.ActiveReservation.MaximumOccupancy);

                    //setup session object requied by the Cancel page
                    ReservationHistoryItem tmp = new ReservationHistoryItem();  //This is the object cancel expect in the session
                    DateTime DateConfirmed     = DateTime.Parse(FormatUtils.GetDate(model.ActiveReservation.DateConfirmed));
                    tmp._DateConfirmed = DateConfirmed.ToString("yyyyMMdd");


                    tmp._Points = model.ActiveReservation.Points;
                    DateTime checkinDate = DateTime.Parse(FormatUtils.GetDate(model.ActiveReservation.CheckInDate));
                    tmp._CheckInDate       = checkinDate.ToString("yyyyMMdd");
                    tmp._ReservationType   = model.ActiveReservation.ReservationType;
                    tmp._NumberOfNights    = model.ActiveReservation.NumberOfNights.ToString();
                    tmp._Amount            = model.ActiveReservation.Amount.ToString();
                    tmp._AmountDue         = model.ActiveReservation.AmountDue.ToString();
                    tmp._ReservationNumber = model.ActiveReservation.ReservationNumber;
                    tmp._ReservationStatus = model.ActiveReservation.ReservationStatus;
                    tmp._GuestFullName     = model.ActiveReservation.Guests[0].FullName;
                    tmp._NumberOfAdults    = model.ActiveReservation.NumberOfAdults;
                    tmp._MaximumOccupancy  = model.ActiveReservation.MaximumOccupancy;
                    tmp._Handicap          = model.ActiveReservation.Handicap;

                    var Room = ResortManager.GetRoom(Convert.ToInt16(model.ActiveReservation.ProjectStay), model.ActiveReservation.AS400UnitType);
                    if (Room != null)
                    {
                        tmp._VillaDescription = Room.ViewTitle;
                    }
                    tmp._PolicyStatus = FormatUtils.PolicyStatus(model.ActiveReservation.PolicyStatus, model.ActiveReservation.EligibleDate, reservationType, model.ActiveReservation.ReservationNumber, model.ActiveReservation.ExchangeCode, model.ActiveReservation.ReservationType);
                    Session["ReservationSelected4Details"] = tmp;


                    Session["PPPStatus"]  = tmp._PolicyStatus;
                    Session["PPPFee"]     = model.ActiveReservation.PolicyPrice;
                    Session["resConfNum"] = model.ActiveReservation.ReservationNumber;

                    //Only get the Guests when reservation is Points
                    if (model.ActiveReservation.ReservationType == "P")
                    {
                        BGSitecore.Services.ResortService resortService = new BGSitecore.Services.ResortService();
                        var allGuest = resortService.OwnerGuestList(bgcontext.OwnerId);
                        if (allGuest != null && allGuest.Guests != null && allGuest.Guests.Count() > 0)
                        {
                            if (model.allGuest == null)
                            {
                                model.allGuest = new List <BGSitecore.Models.ResortService.ScreeningBookReservationResponse.Guest>();
                            }
                            foreach (BGSitecore.Models.ResortService.OwnerGuestList.Guest guest in allGuest.Guests)
                            {
                                if (model.ActiveReservation.Guests != null && model.ActiveReservation.Guests.Count > 0)
                                {
                                    if (guest.GuestID == model.ActiveReservation.Guests[0].GuestID)
                                    {
                                        //Email and phone number are not return with the reservation.  We need to get those values from the list or guests
                                        if (guest.Emails != null && guest.Emails.Count > 0)
                                        {
                                            model.ActiveReservation.Guests[0].Emails = new List <Models.ResortService.ReservationsList.Email>();
                                            Models.ResortService.ReservationsList.Email email = new Models.ResortService.ReservationsList.Email();
                                            email.EmailAddress = guest.Emails[0].EmailAddress;
                                            model.ActiveReservation.Guests[0].Emails.Add(email);
                                        }
                                        if (guest.Phones != null && guest.Phones.Count > 0)
                                        {
                                            model.ActiveReservation.Guests[0].Phones = new List <Models.ResortService.ReservationsList.Phone>();
                                            Models.ResortService.ReservationsList.Phone phone = new Models.ResortService.ReservationsList.Phone();
                                            phone.PhoneNumber = guest.Phones[0].PhoneNumber;
                                            model.ActiveReservation.Guests[0].Phones.Add(phone);
                                        }
                                    }
                                }
                                var findExistingGuest = from existingGuest in model.ActiveReservation.Guests
                                                        where existingGuest.FullName == guest.LastName + " ," + guest.FirstName &&
                                                        existingGuest.GuestID == "0"
                                                        select existingGuest;

                                if (findExistingGuest != null && findExistingGuest.Count() > 0)
                                {
                                    findExistingGuest.First().GuestID = guest.GuestID;
                                }
                                else
                                {
                                    model.allGuest.Add(ReservationUtils.MapOwnerGuestToReservationGuest(guest));
                                }
                            }
                        }
                    }
                }
                return(View(model));
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        public ActionResult UpdateReservation(string ReservationNumber, string ReservationType, string AS400UnitType, string CheckInDate, string ProjectStay, string NumberOfNights, string DropDownName, string newGuest, string NumberOfGuest, string FirstName, string LastName, string Email, string Phone, string City, string State, string Relationship, string MaxOccupancy, string GuestID)
        {
            JsonResponse jsonResponse = new JsonResponse();

            jsonResponse.errors  = new List <string>();
            jsonResponse.RetCode = "0";  //default to error
            ReservationHistoryItem sessionObject = (ReservationHistoryItem)Session["ReservationSelected4Details"];

            if (jsonResponse.errors.Count <= 0)
            {
                ModifyReservationRequest request = new ModifyReservationRequest();
                if (ReservationType == "P")
                {
                    request.SiteName        = "onlinepoints";
                    request.ReservationType = "P";
                    request.Points          = sessionObject._Points;
                }
                else
                {
                    request.SiteName        = "BonusTime";
                    request.ReservationType = "B";
                }
                BlueGreenContext bgContext = new BlueGreenContext();
                request.OwnerID = FormatUtils.ConvertStringToInt(bgContext.OwnerId);
                request.ReservationProjectNumber = ProjectStay;
                request.UnitTypeCode             = AS400UnitType;
                DateTime checkIn = DateTime.Parse(FormatUtils.GetDate(CheckInDate));

                request.CheckInDate       = checkIn.ToString("MM/dd/yyyy");
                request.LengthOfStay      = FormatUtils.ConvertStringToInt(NumberOfNights);
                request.ReservationNumber = ReservationNumber;
                request.NumberOfAdults    = FormatUtils.ConvertStringToInt(NumberOfGuest);
                request.Guests            = new List <Models.ResortService.ModifyReservationRequest.Guest>();
                if (newGuest == "OwnerSelected")
                {
                    Models.ResortService.ModifyReservationRequest.Guest guest = new Models.ResortService.ModifyReservationRequest.Guest();

                    guest.GuestType = "Primary";
                    //guest.GuestID = FormatUtils.ConvertStringToInt(GuestID);
                    guest.FirstName = FirstName;
                    guest.LastName  = LastName;
                    request.Guests.Add(guest);
                }
                else
                {
                    Models.ResortService.ModifyReservationRequest.Guest guest = new Models.ResortService.ModifyReservationRequest.Guest();

                    guest.GuestType    = "GuestOnPrimary";
                    guest.GuestID      = FormatUtils.ConvertStringToInt(GuestID);
                    guest.FirstName    = FirstName;
                    guest.LastName     = LastName;
                    guest.Relationship = Relationship;
                    if (!string.IsNullOrEmpty(Email))
                    {
                        guest.EmailAddresses = new List <Models.ResortService.ModifyReservationRequest.EmailAddress>();
                        var email = new Models.ResortService.ModifyReservationRequest.EmailAddress();
                        email.AddressType = "Home";
                        email.Email       = Email;
                        guest.EmailAddresses.Add(email);
                    }
                    guest.Addresses = new List <Models.ResortService.ModifyReservationRequest.Address>();
                    var address = new Models.ResortService.ModifyReservationRequest.Address();
                    address.AddressType  = "Home";
                    address.City         = City;
                    address.ProvinceCode = State;

                    guest.Addresses.Add(address);

                    if (!string.IsNullOrEmpty(Phone))
                    {
                        guest.Phones = new List <Models.ResortService.ModifyReservationRequest.Phone>();
                        var phone = new Models.ResortService.ModifyReservationRequest.Phone();
                        phone.PhoneNumberType = "Home";
                        phone.PhoneNumber     = Phone;
                        guest.Phones.Add(phone);
                    }
                    request.Guests.Add(guest);
                }

                ResortService resortService = new Services.ResortService();

                var response = resortService.ModifyReservation(request);
                if (response.Errors == null)
                {
                    sessionObject._GuestFullName           = LastName + ", " + FirstName;
                    sessionObject._NumberOfAdults          = NumberOfGuest;
                    Session["ReservationSelected4Details"] = sessionObject;
                    jsonResponse.RetCode = "0";
                }
                else
                {
                    jsonResponse.errors.Add("Error updating the reservation");
                }
            }
            return(Json(jsonResponse));
        }