コード例 #1
0
        private void GenerateNonAccessibleBlocks(ObservableCollection <ScheduleReservation> appointmentCollection)
        {
            for (var i = 0; i < 7; i++)
            {
                var lastToTime    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
                var dayOfWeekDate = DateTime.Now;
                var weekDay       = WeekDays.Sunday;
                RecurrenceProperties recurrenceProperties;
                ScheduleReservation  scheduleAppointment;
                foreach (var dayAndTime in Resource.Available.Where(d => d.DayOfWeek == (DayOfWeek)i).OrderBy(x => x.From))
                {
                    dayOfWeekDate = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + (int)dayAndTime.DayOfWeek);
                    lastToTime    = new DateTime(dayOfWeekDate.Year, dayOfWeekDate.Month, dayOfWeekDate.Day, lastToTime.Hour, lastToTime.Minute, 0);
                    Enum.TryParse <WeekDays>(dayAndTime.DayOfWeek.ToString(), out weekDay);

                    recurrenceProperties = new RecurrenceProperties
                    {
                        RecurrenceType  = RecurrenceType.Weekly,
                        Interval        = 1,
                        WeekDays        = weekDay,
                        RecurrenceRange = RecurrenceRange.NoEndDate
                    };

                    scheduleAppointment = new ScheduleReservation()
                    {
                        ReservationId = Guid.NewGuid(),
                        StartTime     = lastToTime,
                        EndTime       = new DateTime(dayOfWeekDate.Year, dayOfWeekDate.Month, dayOfWeekDate.Day, dayAndTime.From.Hour, dayAndTime.From.Minute, 0),
                        Subject       = "Not Available",
                        Color         = Color.LightGray,
                    };
                    appointmentCollection.Add(scheduleAppointment);

                    scheduleAppointment.RecurrenceRule = DependencyService.Get <IRecurrenceBuilder>().RRuleGenerator(recurrenceProperties, scheduleAppointment.StartTime, scheduleAppointment.EndTime);

                    lastToTime = new DateTime(dayOfWeekDate.Year, dayOfWeekDate.Month, dayOfWeekDate.Day, dayAndTime.To.Hour, dayAndTime.To.Minute, 0);
                }

                recurrenceProperties = new RecurrenceProperties
                {
                    RecurrenceType  = RecurrenceType.Weekly,
                    Interval        = 1,
                    WeekDays        = weekDay,
                    RecurrenceRange = RecurrenceRange.NoEndDate
                };

                scheduleAppointment = new ScheduleReservation()
                {
                    ReservationId = Guid.NewGuid(),
                    StartTime     = lastToTime,
                    EndTime       = new DateTime(dayOfWeekDate.Year, dayOfWeekDate.Month, dayOfWeekDate.Day, 23, 59, 59),
                    Subject       = "Not Available",
                    Color         = Color.LightGray,
                };
                appointmentCollection.Add(scheduleAppointment);

                scheduleAppointment.RecurrenceRule = DependencyService.Get <IRecurrenceBuilder>().RRuleGenerator(recurrenceProperties, scheduleAppointment.StartTime, scheduleAppointment.EndTime);
            }
        }
コード例 #2
0
        public UpdateReservationViewModel(INavigationService navigator, string navigationPath, Domain.Entities.Reservation reservation, ObservableCollection <ScheduleReservation> reservations)
        {
            #region Navigation
            NavigationPath = navigationPath;
            _navigator     = navigator;
            #endregion

            _reservation        = reservation;
            fromTime            = new TimeSpan(reservation.From.Hour, reservation.From.Minute, 0);
            toTime              = new TimeSpan(reservation.To.Hour, reservation.To.Minute, 0);
            _reservations       = reservations;
            ScheduleReservation = _reservations.FirstOrDefault(r => r.ReservationId == reservation.Id);
        }