Ejemplo n.º 1
0
        public List <DateTime> WeeklyRecurring(BookingEdit booking, int increment)
        {
            int      weekIncrement  = 7 * increment;
            DateTime recurringStart = booking.StartDate.Date;

            List <DateTime> bookingDates = new List <DateTime>();

            bookingDates.Add(booking.StartDate.Date);

            foreach (var date in booking.DayList)
            {
                if (date.isSelected)
                {
                    if (date.DateOfDay < recurringStart) /*&& (date.DateOfDay <= booking.RepeadEnd)*/
                    {
                        date.DateOfDay = date.DateOfDay.AddDays(weekIncrement);
                    }
                    for (DateTime rDate = date.DateOfDay; rDate <= booking.RepeadEnd; rDate = rDate.AddDays(weekIncrement))
                    {
                        bookingDates.Add(rDate);
                    }
                }
            }
            return(bookingDates);
        }
Ejemplo n.º 2
0
        public BookingEdit GetEdit(Booking booking)
        {
            var bookingEdit = new BookingEdit();

            //var start = starttime1.TimeOfDay;
            var start            = booking.StartTime.TimeOfDay;;
            var slotDurationMins = int.Parse(ConfigurationManager.AppSettings["SlotDurationMins"]);

            //string stime = starttime1.TimeOfDay.ToString();

            bookingEdit.BookingId           = booking.BookingId;
            bookingEdit.BookingTypeDropDown = GetBookingType(booking.BookingType.ToString());
            bookingEdit.StartTimeDropDown   = GetTimeDropDownList(start);
            bookingEdit.EndTimeDropDown     = GetTimeDropDownList(start.Add(new TimeSpan(0, slotDurationMins, 0)));
            bookingEdit.RoomsDropDown       = GetRooms(booking.RoomId);
            bookingEdit.DateCreated         = booking.DateCreated;;
            bookingEdit.StartDate           = booking.StartTime;
            bookingEdit.EndDate             = booking.EndTime;
            bookingEdit.Title        = booking.Title;
            bookingEdit.Description  = booking.Description;
            bookingEdit.Confirmation = booking.Confirmation;


            return(bookingEdit);
        }
Ejemplo n.º 3
0
        public BookingEdit GetBookingEdit(DateTime date, DateTime starttime1, DateTime endtime1, string roomname, string viewName)
        {
            var bookingEdit = new BookingEdit();

            var    start            = starttime1.TimeOfDay;
            var    slotDurationMins = int.Parse(ConfigurationManager.AppSettings["SlotDurationMins"]);
            string stime            = starttime1.TimeOfDay.ToString();

            bookingEdit.BookingTypeDropDown    = GetBookingType();
            bookingEdit.StartTimeDropDown      = GetTimeDropDownList(start);
            bookingEdit.EndTimeDropDown        = GetTimeDropDownList(start.Add(new TimeSpan(0, slotDurationMins, 0)));
            bookingEdit.RoomsDropDown          = GetRooms(roomname);
            bookingEdit.DateCreated            = DateTime.Now;
            bookingEdit.StartDate              = date;
            bookingEdit.EndDate                = date;
            bookingEdit.RepeadEnd              = date;
            bookingEdit.DayList                = GetWeekDays(date);
            bookingEdit.DayOfMonthDropDown     = GetDayOfMonthDropDown();
            bookingEdit.MonthIncrementDropDown = GetMonthlyIncrement();
            bookingEdit.MonthDayDropDown       = GetMonthlyDayList();


            //hidden properties
            bookingEdit.ViewName     = viewName;
            bookingEdit.ViewRoomName = roomname;

            return(bookingEdit);
        }
Ejemplo n.º 4
0
        public List <DateTime> MonthlyIncrement(BookingEdit booking)
        {
            List <DateTime> bookingDates = new List <DateTime>();

            bookingDates.Add(booking.StartDate.Date);

            if (int.Parse(booking.MonthIncrement) <= 4)
            {
                int count = 0;

                DateTime firstbooking = new DateTime(booking.StartDate.Year, booking.StartDate.Month, booking.StartDate.Day);

                for (DateTime dt = firstbooking; dt < booking.RepeadEnd; dt = dt.AddMonths(1))
                {
                    count = 0;
                    int daysInMonth = DateTime.DaysInMonth(dt.Year, dt.Month);

                    for (int day = 1; day <= daysInMonth; day++)
                    {
                        DateTime currentDateTime = new DateTime(dt.Year, dt.Month, day);
                        if (currentDateTime.DayOfWeek.ToString() == booking.MonthDay)
                        {
                            count++;

                            if (count == int.Parse(booking.MonthIncrement))
                            {
                                bookingDates.Add(currentDateTime);
                                break;
                            }
                        }
                    }
                }
            }

            else
            {
                DateTime firstbooking = new DateTime(booking.StartDate.Year, booking.StartDate.Month, booking.StartDate.Day);

                for (DateTime dt = firstbooking; dt < booking.RepeadEnd; dt = dt.AddMonths(1))
                {
                    int daysInMonth = DateTime.DaysInMonth(dt.Year, dt.Month);

                    for (int day = daysInMonth; day > 0; day--)
                    {
                        DateTime currentDateTime = new DateTime(dt.Year, dt.Month, day);
                        if (currentDateTime.DayOfWeek.ToString() == booking.MonthDay)
                        {
                            bookingDates.Add(currentDateTime);
                            break;
                        }
                    }
                }
            }
            return(bookingDates);
        }
Ejemplo n.º 5
0
        public List <DateTime> DailyRecurring(BookingEdit booking)
        {
            List <DateTime> bookingDates = new List <DateTime>();

            //bookingDates.Add(booking.StartDate.Date);

            while (booking.StartDate < booking.RepeadEnd)
            {
                bookingDates.Add(booking.StartDate.Date);

                booking.StartDate = booking.StartDate.AddDays(1);
            }
            return(bookingDates);
        }
Ejemplo n.º 6
0
        public List <DateTime> MonthlyByDay(BookingEdit booking)
        {
            int day = int.Parse(booking.DayOfMonth);

            //DateTime firstbooking = new DateTime(booking.StartDate.Year, booking.StartDate.Month, day);

            List <DateTime> bookingDates = new List <DateTime>();

            bookingDates.Add(booking.StartDate.Date);

            if (day >= 1 && day <= 28)
            {
                DateTime firstbooking = new DateTime(booking.StartDate.Year, booking.StartDate.Month, day);

                for (DateTime dt = firstbooking; dt < booking.RepeadEnd; dt = dt.AddMonths(1))
                {
                    bookingDates.Add(dt);
                }
            }
            else
            {
                DateTime firstbooking = new DateTime(booking.StartDate.Year, booking.StartDate.Month, 1);

                for (DateTime dt = firstbooking; dt < booking.RepeadEnd; dt = dt.AddMonths(1))
                {
                    int daysinmonth = DateTime.DaysInMonth(dt.Year, dt.Month);

                    if (daysinmonth >= day)
                    {
                        DateTime newbookingdate = new DateTime(dt.Year, dt.Month, day);

                        bookingDates.Add(newbookingdate);
                    }
                    else
                    {
                        DateTime endofmonth = new DateTime(dt.Year, dt.Month, daysinmonth);

                        bookingDates.Add(endofmonth);
                    }
                }
            }
            return(bookingDates);
        }