Beispiel #1
0
        //this function creates a BookingDate for every booking date and adds it to the list of booking dates
        public void GetAllBookingDatesAndAddToThisCalendar()
        {
            PortugalVillasContext _db             = new PortugalVillasContext();
            List <Booking>        theBookingDates = Booking.GetAllBookingsForAProperty(this.PropertyID);
            var externalDates = BookingExternal.GetExternalBookingsAsBookings(this.PropertyID);

            //add external dates
            theBookingDates.AddRange(externalDates);

            //add our system dates
            if (theBookingDates.Any())
            {
                //create and add each booked date to the 'bookingDates' list.
                foreach (Booking aBooking in theBookingDates)
                {
                    try
                    {
                        if (aBooking.Confirmed == true && aBooking.Cancelled == false)
                        {
                            //foreach booking
                            DateTime    tempDate        = aBooking.StartDate.Value;
                            BookingDate tempBookingDate = new BookingDate();

                            switch (aBooking.Confirmed)
                            {
                            case true:
                                tempBookingDate.bookingDateType = BookingDate.BookingDateType.Confirmed;
                                break;

                                /* case false:
                                 * tempBookingDate.bookingDateType = BookingDate.BookingDateType.Provisional;
                                 * break;*/
                            }

                            //THIS STOPS A DAY BEFORE THE ACTUAL BOOKING
                            //add a new booking date to the list - stop at last date as we want that to be available for another booking
                            while (tempDate < aBooking.EndDate)
                            {
                                bookingDates.Add(
                                    new BookingDate()
                                {
                                    bookingDate     = tempDate,
                                    bookingDateType = tempBookingDate.bookingDateType
                                });
                                tempDate = tempDate.AddDays(1);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        //ignore it, process the next one
                    }
                }
            }
        }
        //this function creates a BookingDate for every booking date and adds it to the list of booking dates
        public void GetAllBookingDatesAndAddToThisCalendar()
        {
            PortugalVillasContext _db = new PortugalVillasContext();
            List<Booking> theBookingDates = Booking.GetAllBookingsForAProperty(this.PropertyID);

            //create and add each booked date to the 'bookingDates' list.
            foreach (Booking aBooking in theBookingDates)
            {
                //foreach booking
                DateTime tempDate = aBooking.StartDate.Value;
                BookingDate tempBookingDate = new BookingDate();

                switch (aBooking.Confirmed)
                {
                    case true:
                        tempBookingDate.bookingDateType = BookingDate.BookingDateType.Confirmed;
                        break;
                    case false:
                        tempBookingDate.bookingDateType = BookingDate.BookingDateType.Provisional;
                        break;

                }

                //add a new booking date to the list - stop at last date as we want that to be available for another booking
                while (tempDate < aBooking.EndDate)
                {

                    bookingDates.Add(
                        new BookingDate()
                            {
                                bookingDate = tempDate,
                                bookingDateType = tempBookingDate.bookingDateType

                       });
                    tempDate = tempDate.AddDays(1);
                }

            }
        }
        //this function creates a BookingDate for every booking date and adds it to the list of booking dates
        public void GetAllBookingDatesAndAddToThisCalendar()
        {
            PortugalVillasContext _db = new PortugalVillasContext();
            List<Booking> theBookingDates = Booking.GetAllBookingsForAProperty(this.PropertyID);
            var externalDates = BookingExternal.GetExternalBookingsAsBookings(this.PropertyID);

            //add external dates
            theBookingDates.AddRange(externalDates);

            //add our system dates
            if (theBookingDates.Any())
            {

                //create and add each booked date to the 'bookingDates' list. 
                foreach (Booking aBooking in theBookingDates)
                {
                    try
                    {

                        if (aBooking.Confirmed == true && aBooking.Cancelled == false)
                        {
                            //foreach booking 
                            DateTime tempDate = aBooking.StartDate.Value;
                            BookingDate tempBookingDate = new BookingDate();

                            switch (aBooking.Confirmed)
                            {
                                case true:
                                    tempBookingDate.bookingDateType = BookingDate.BookingDateType.Confirmed;
                                    break;
                                    /* case false:
                                tempBookingDate.bookingDateType = BookingDate.BookingDateType.Provisional;
                                break;*/

                            }

                            //THIS STOPS A DAY BEFORE THE ACTUAL BOOKING 
                            //add a new booking date to the list - stop at last date as we want that to be available for another booking
                            while (tempDate < aBooking.EndDate)
                            {

                                bookingDates.Add(
                                    new BookingDate()
                                    {
                                        bookingDate = tempDate,
                                        bookingDateType = tempBookingDate.bookingDateType

                                    });
                                tempDate = tempDate.AddDays(1);
                            }
                        }

                    }
                    catch (Exception ex)
                    {
                        
                        //ignore it, process the next one
                    }


                }
            }


        }