예제 #1
0
        /// <summary>
        /// SRP: Creates list of objects for this Customer based on what's in session
        /// - DO we have a customer
        /// - Do we have bank details
        /// - Collect All Booking Details and Extra Details
        /// </summary>
        /// <returns></returns>
        public Dictionary <BookingDataCollectionEventType.Types, BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect> CreateListOfFieldsToGatherBasedOnSessionData()
        {
            try
            {
                List <BookingDataCollectionEventType.Types> whatDataNeedsToBeGathered = new List <BookingDataCollectionEventType.Types>();
                Dictionary <BookingDataCollectionEventType.Types, BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect> DataThatNeedsGetting = new Dictionary <BookingDataCollectionEventType.Types, BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect>();

                //pull customer data if exists, else  corresponding  dataset object
                if (!TestForSessionVariable("prc_customer"))
                {  //there's nothing, add customer to the list
                    DataThatNeedsGetting.Add(BookingDataCollectionEventType.Types.Customer, new BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect {
                        Action = "CreateCustomer", Controller = "FinalBookingDetailGathering"
                    });
                }

                //pull customer banking details
                if (!TestForSessionVariable("prc_customerBankingDetail"))
                {
                    DataThatNeedsGetting.Add(BookingDataCollectionEventType.Types.Payment, new BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect {
                        Action = "CreateCustomerBankDetail", Controller = "FinalBookingDetailGathering"
                    });
                }

                //pull all property bookings from the session and generate corresponding  dataset objects

                if (Session["Cart_PropertyBookings"] != null)
                {
                    List <Booking> theBookings = (List <Booking>)Session["Cart_PropertyBookings"];
                    //foreach booking generate a list of things to grab, then add it to the Dictionary

                    //test if we have a data gathering object in the session matching every booking - if so, ignore, else add

                    foreach (var booking in theBookings)
                    {
                        //test if we have a data gathering object in the session matching every booking - if so, ignore, else add
                        //  if (Session[String.Format("booking_{0}_{1}_{2}_{3}", booking.PropertyID.ToString(), booking.BookingPRCReference, booking.StartDate.ToString(), booking.EndDate.ToString())] == null)
                        //generate customer data collection attributes and add to the set
                        // {
                        //    Session[String.Format("booking_{0}_{1}_{2}_{3}", booking.PropertyID.ToString(), booking.BookingPRCReference, booking.StartDate.ToString(), booking.EndDate.ToString())] = booking;
                        BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect aRedirect = new BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect {
                            Action = "CreateBooking", Controller = "FinalBookingDetailGathering", CompositeBookingID = booking.PropertyID + "_" + booking.BookingPRCReference + "_" + booking.StartDate + "_" + booking.StartDate, PRCRef = booking.BookingPRCReference, PropertyID = (long?)booking.PropertyID, StartDate = booking.StartDate, EndDate = booking.EndDate, NoLinen = booking.ExtraLininSet, NoSwimmingPool = booking.SwimmingPoolHeating, NoTowels = booking.NoOfTowelsRequested, Price = booking.BookingPrice
                        };
                        if (booking.SpecialRequests != null)
                        {
                            aRedirect.SpecialRequests = booking.SpecialRequests;
                        }
                        else
                        {
                            aRedirect.SpecialRequests = "";
                        }


                        DataThatNeedsGetting.Add(BookingDataCollectionEventType.Types.Booking, aRedirect);
                        // }
                    }
                }

                //pull all extra bookings from the session and corresponding  dataset objects

                if (Session["Cart_ExtraBookings"] != null)
                {
                    List <BookingExtraSelection> theExtraBookings = (List <BookingExtraSelection>)Session["Cart_ExtraBookings"];

                    foreach (var bookingExtra in theExtraBookings)
                    {
                        BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect aRedirect = new BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect {
                            Action = "CreateBookingExtraSelection", Controller = "FinalBookingDetailGathering", CompositeBookingID = bookingExtra.BookingExtraPRCReference + "_" + bookingExtra.ExtraRentalDate + "_" + bookingExtra.ExtraReturnDate, PRCRef = bookingExtra.BookingExtraPRCReference, StartDate = bookingExtra.ExtraRentalDate, EndDate = bookingExtra.ExtraReturnDate, ExtraTypeID = bookingExtra.BookingExtraID, Price = bookingExtra.BESPrice
                        };
                        if (bookingExtra.BESSpecialRequests != null)
                        {
                            aRedirect.SpecialRequests = bookingExtra.BESSpecialRequests;
                        }
                        else
                        {
                            aRedirect.SpecialRequests = "";
                        }

                        DataThatNeedsGetting.Add(BookingDataCollectionEventType.Types.BookingExtraSelection, aRedirect);
                    }
                }



                return(DataThatNeedsGetting);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// SRP: Creates list of objects for this Customer based on what's in session
        /// - DO we have a customer
        /// - Do we have bank details
        /// - Collect All Booking Details and Extra Details
        /// </summary>
        /// <returns></returns>
        public Dictionary<BookingDataCollectionEventType.Types, BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect> CreateListOfFieldsToGatherBasedOnSessionData()
        {

            try
            {


                List<BookingDataCollectionEventType.Types> whatDataNeedsToBeGathered = new List<BookingDataCollectionEventType.Types>();
                Dictionary<BookingDataCollectionEventType.Types, BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect> DataThatNeedsGetting = new Dictionary<BookingDataCollectionEventType.Types, BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect>();

                //pull customer data if exists, else  corresponding  dataset object
                if (!TestForSessionVariable("prc_customer"))
                {  //there's nothing, add customer to the list
                    DataThatNeedsGetting.Add(BookingDataCollectionEventType.Types.Customer, new BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect { Action = "CreateCustomer", Controller = "FinalBookingDetailGathering" });
                }

                //pull customer banking details
                if (!TestForSessionVariable("prc_customerBankingDetail"))
                {
                    DataThatNeedsGetting.Add(BookingDataCollectionEventType.Types.Payment, new BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect { Action = "CreateCustomerBankDetail", Controller = "FinalBookingDetailGathering" });
                }

                //pull all property bookings from the session and generate corresponding  dataset objects   

                if (Session["Cart_PropertyBookings"] != null)
                {

                    List<Booking> theBookings = (List<Booking>)Session["Cart_PropertyBookings"];
                    //foreach booking generate a list of things to grab, then add it to the Dictionary                

                    //test if we have a data gathering object in the session matching every booking - if so, ignore, else add

                    foreach (var booking in theBookings)
                    {
                        //test if we have a data gathering object in the session matching every booking - if so, ignore, else add
                        //  if (Session[String.Format("booking_{0}_{1}_{2}_{3}", booking.PropertyID.ToString(), booking.BookingPRCReference, booking.StartDate.ToString(), booking.EndDate.ToString())] == null)
                        //generate customer data collection attributes and add to the set
                        // {
                        //    Session[String.Format("booking_{0}_{1}_{2}_{3}", booking.PropertyID.ToString(), booking.BookingPRCReference, booking.StartDate.ToString(), booking.EndDate.ToString())] = booking;
                        BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect aRedirect = new BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect { Action = "CreateBooking", Controller = "FinalBookingDetailGathering", CompositeBookingID = booking.PropertyID + "_" + booking.BookingPRCReference + "_" + booking.StartDate + "_" + booking.StartDate, PRCRef = booking.BookingPRCReference, PropertyID = (long?)booking.PropertyID, StartDate = booking.StartDate, EndDate = booking.EndDate, NoLinen = booking.ExtraLininSet, NoSwimmingPool = booking.SwimmingPoolHeating, NoTowels = booking.NoOfTowelsRequested, Price = booking.BookingPrice };
                        if (booking.SpecialRequests != null)
                        { aRedirect.SpecialRequests = booking.SpecialRequests; }
                        else aRedirect.SpecialRequests = "";


                        DataThatNeedsGetting.Add(BookingDataCollectionEventType.Types.Booking, aRedirect);
                        // }
                    }

                }

                //pull all extra bookings from the session and corresponding  dataset objects

                if (Session["Cart_ExtraBookings"] != null)
                {
                    List<BookingExtraSelection> theExtraBookings = (List<BookingExtraSelection>)Session["Cart_ExtraBookings"];

                    foreach (var bookingExtra in theExtraBookings)
                    {


                        BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect aRedirect = new BookingDataCollectionEventType.PRCDataGatheringControllerActionRedirect { Action = "CreateBookingExtraSelection", Controller = "FinalBookingDetailGathering", CompositeBookingID = bookingExtra.BookingExtraPRCReference + "_" + bookingExtra.ExtraRentalDate + "_" + bookingExtra.ExtraReturnDate, PRCRef = bookingExtra.BookingExtraPRCReference, StartDate = bookingExtra.ExtraRentalDate, EndDate = bookingExtra.ExtraReturnDate, ExtraTypeID = bookingExtra.BookingExtraID, Price = bookingExtra.BESPrice };
                        if (bookingExtra.BESSpecialRequests != null)
                        { aRedirect.SpecialRequests = bookingExtra.BESSpecialRequests; }
                        else aRedirect.SpecialRequests = "";

                        DataThatNeedsGetting.Add(BookingDataCollectionEventType.Types.BookingExtraSelection, aRedirect);
                    }

                }



                return DataThatNeedsGetting;


            }
            catch (Exception ex)
            {

                throw ex;
            }



        }