Exemplo n.º 1
0
        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());
        }