public ActionResult ConfirmReservationSubmit(ReservationParameters model)
        {
            model.AcceptTermsAndConditions = (HttpContext.Request.Form["confirm_toc"] != null);

            ReservationParameters reservationContext = ReservationUtils.GetContextReservation();

            Session["PPPUiError"] = null;
            ValidationUtils.ClearModelErrors(ModelState);

            reservationContext = ReservationUtils.MapGuestValues(model, reservationContext);
            // var errors = ValidationUtils.GetGuestViolations(model, reservationContext.MaxOccupancy);
            var errors = new List <RuleViolation>();

            if (!ValidationUtils.ErrorsDetected(ModelState, errors))
            {
                Session["ReservationContext"] = reservationContext;
                var reservationResponse = ExecuteBook(reservationContext);

                if (reservationResponse != null && reservationResponse.Errors == null)
                {
                    OwnerUtils.SetContextToReloadPalett();

                    Session["ReservationNumber"] = reservationResponse.ConfirmReservation.ReservationNumber;
                    Response.Redirect("/owner/Points-Protection-Plan", false);
                    return(null);
                }
                else
                {
                    ModelState.AddModelError("", "We're sorry, but since you began your search, that villa type is no longer available. Please select BACK to begin a new search.");
                }
            }

            return(base.Index());
        }
        public ActionResult ResortPreviewDetails()
        {
            DebugUtils.StartLogEvent("ReservationController.ResortPreviewDetails");

            var model = GetLayoutItem <ResortPreviewDetails>();

            ResortDetails resortDetail = null;


            if (Session["ActiveReservation"] != null)
            {
                Reservation activeReservation = (Reservation)Session["ActiveReservation"];
                resortDetail             = ResortManager.GetResortByProject(activeReservation.ProjectStay);
                model.ActiveReservation  = activeReservation;
                model.HandicapAccessible = false;

                ResortService resortService = new ResortService();
                var           UnitInfo      = resortService.GetUnitInfo(model.ActiveReservation.ProjectStay, model.ActiveReservation.AS400UnitType, model.ActiveReservation.UnitNumber);
                if (UnitInfo != null)
                {
                    model.HandicapAccessible = (UnitInfo.HandicapAccessible == "1");
                }

                Session["ActiveReservation"] = null;
            }
            else
            {
                ReservationParameters reservationContext = ReservationUtils.GetContextReservation();

                if (reservationContext != null)
                {
                    resortDetail            = ResortManager.FindResort(reservationContext.ResortId);
                    model.ActiveReservation = new BGSitecore.Models.ResortService.ReservationsList.Reservation();
                    model.ActiveReservation.AS400UnitType    = reservationContext.UnitType;
                    model.ActiveReservation.ProjectStay      = reservationContext.ProjectNumber.ToString();
                    model.ActiveReservation.CheckInDate      = reservationContext.CheckInDate.ToString("yyyyMMdd");
                    model.ActiveReservation.CheckOutDate     = reservationContext.CheckOutDate.ToString("yyyyMMdd");
                    model.ActiveReservation.ReservationType  = reservationContext.ReservationType;
                    model.ActiveReservation.Points           = reservationContext.PointsRequired.ToString();
                    model.ActiveReservation.MaximumOccupancy = reservationContext.MaxOccupancy.ToString();

                    model.ActiveReservation.Amount = reservationContext.BT_TotalCost;
                    model.HandicapAccessible       = (!string.IsNullOrEmpty(reservationContext.wheelchairaccessible) && (reservationContext.wheelchairaccessible == "1"));
                }
            }
            model.ResortDetail = resortDetail;
            DebugUtils.EndLogEvent("ReservationController.ResortPreviewDetails");

            return(View(model));
        }
        public ActionResult BonusTimeReservationSubmit(ReservationParameters model)
        {
            model.AcceptTermsAndConditions = (HttpContext.Request.Form["confirm_toc"] != null);
            ReservationParameters reservationContext = ReservationUtils.GetContextReservation();

            reservationContext.CreditCard_Type = FormatUtils.ConvertCreditCard(model.CreditCard_Type); //Required for the validation
            var listOfError = ValidationUtils.GetCreditCardViolations(model);

            listOfError.AddRange(ValidationUtils.GetAddressViolations(model));
            listOfError.AddRange(ValidationUtils.GetGuestViolations(model, reservationContext.MaxOccupancy));
            Session["ChangedCountry"] = null;
            if (listOfError.Count > 0)
            {
                Session["ChangedCountry"] = model.Address_Country;
                foreach (var vi in listOfError)
                {
                    ModelState.AddModelError("", vi.ErrorMessage);
                }
            }
            else
            {
                reservationContext = ReservationUtils.MapGuestValues(model, reservationContext);
                reservationContext = ReservationUtils.MapAddressValues(model, reservationContext);
                reservationContext = ReservationUtils.MapCreditCardValues(model, reservationContext);

                var reservationResponse = ExecuteBook(reservationContext);
                if (reservationResponse != null && reservationResponse.Errors == null)
                {
                    ReservationUtils.DeleteContextReservation();
                    //Response.Flush();
                    Response.Redirect("/owner/reservation-confirmation?type=Future&reservationNo=" + reservationResponse.ConfirmReservation.ReservationNumber, false);
                    HttpContext.ApplicationInstance.CompleteRequest();
                    return(null);
                }
                else
                {
                    ModelState.AddModelError("", "We're sorry, but since you began your search, that villa type is no longer available. Please select BACK to begin a new search.");
                }
            }

            return(base.Index());
        }
        public ActionResult PointsProtectionPlan()
        {
            var model = GetLayoutItem <PointsProtectionPlan>();

            if (Request.QueryString["reservationNo"] == null)
            {
                ReservationParameters reservationContext = ReservationUtils.GetContextReservation();
                if (reservationContext == null)
                {
                    ReservationUtils.HandelMissingReservationContext();
                }
                else
                {
                    model.payment = reservationContext.PPPCost.ToString();
                    model.points  = reservationContext.PointsRequired;
                }
            }
            else
            {
                //Get the reservation details from service call
                BlueGreenContext bgcontext = new BlueGreenContext();
                var ActiveReservation      = bgcontext.GetActiveReservation(Request.QueryString["reservationNo"], ResortService.RESERVATION_TYPE_FUTURE);
                model.payment = ActiveReservation.PolicyPrice;
                model.points  = FormatUtils.ConvertStringToInt(ActiveReservation.Points);
                Session["ReservationNumber"] = ActiveReservation.ReservationNumber;
                ReservationParameters reservationContext = new ReservationParameters();
                reservationContext.PPPCost        = Convert.ToDecimal(model.payment);
                reservationContext.PointsRequired = FormatUtils.ConvertStringToInt(ActiveReservation.Points);
                Session["ReservationContext"]     = reservationContext;
            }
            if (Session["PPPUiError"] != null)
            {
                var allPreviousError = (List <RuleViolation>)Session["PPPUiError"];
                foreach (RuleViolation item in allPreviousError)
                {
                    ModelState.AddModelError("", item.ErrorMessage);
                }
                Session["PPPUiError"] = null;
            }

            return(View(model));
        }
        public ActionResult SubmitPPP(BGSitecore.Models.ReservationParameters model)
        {
            DebugUtils.StartLogEvent("ReservationController.SubmitPPP");

            ReservationParameters reservationContext = ReservationUtils.GetContextReservation();

            model.CreditCard_Type = FormatUtils.ConvertCreditCard(reservationContext.CreditCard_Type);
            if (model.btnSubmit == "action:nocreditcard")
            {
                DeclinePointsProtectionRequest request = new DeclinePointsProtectionRequest();
                request.SiteName          = "";
                request.ReservationNumber = Session["ReservationNumber"].ToString();

                ResortService service           = new ResortService();
                var           response          = service.DeclinePointsProtection(request);
                var           reservationNUmber = Session["ReservationNumber"].ToString();
                PPPOwnerWebStats(reservationContext, false);

                ReservationUtils.DeleteContextReservation();

                Response.Redirect("/owner/reservation-confirmation?bv=true&type=Future&reservationNo=" + reservationNUmber, false);
                return(null);
            }
            else
            {
                var listOfError = ValidationUtils.GetCreditCardViolations(model);
                if (listOfError.Count() <= 0)
                {
                    AcceptPointsProtectionRequest request = new AcceptPointsProtectionRequest();
                    request.SiteName                         = "OnlinePoints";
                    request.ReservationNumber                = Session["ReservationNumber"].ToString();
                    request.Payment                          = new Models.ResortService.AcceptPointsProtection.Payment();
                    request.Payment.CreditCardNumber         = model.CreditCard_Number;
                    request.Payment.CreditCardExpirationDate = ReservationUtils.GetExpDate(model.CreditCard_ExpDateMonth, model.CreditCard_ExpDateYear);
                    request.Payment.CreditCardType           = "V"; // model.CreditCard_Type;
                    request.Payment.CreditCardName           = model.CreditCard_Name;
                    request.Payment.CreditCardAuthorization  = model.CreditCard_VerificationNumber;
                    request.Payment.CreditCardTotal          = Convert.ToString(reservationContext.PPPCost);
                    request.Payment.NonTaxTotal              = "";
                    ResortService service     = new ResortService();
                    var           pppResponse = service.AcceptPointsProtection(request);
                    if (pppResponse == null || pppResponse.Errors != null)
                    {
                        //TODO move this message in sitecore
                        listOfError.Add(new RuleViolation("", "", "Unfortunately, we have encountered a technical error while processing Points Protection Plan.Please call 800.456.CLUB(2582) to report the problem and receive assistance.Thank you."));
                        Session["PPPUiError"] = listOfError;
                    }
                    else
                    {
                        var reservationNUmber = Session["ReservationNumber"].ToString();
                        PPPOwnerWebStats(reservationContext, true);
                        ReservationUtils.DeleteContextReservation();
                        DebugUtils.StartLogEvent("ReservationController.SubmitPPP");

                        Response.Redirect("/owner/reservation-confirmation?bv=true&reservationNo=" + reservationNUmber, false);
                        return(null);
                    }
                }
                else
                {
                    Session["PPPUiError"] = listOfError;
                }
            }

            DebugUtils.StartLogEvent("ReservationController.SubmitPPP");

            return(base.Index());
        }