Пример #1
0
        private void RoomClock_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var checkDate = ViewModel.SelectedDate;

            var time    = e.AddedItems[0].ToString();
            int hours   = Convert.ToInt32(time.Substring(0, 2));
            int minutes = Convert.ToInt32(time.Substring(3, 2));

            var dateTime = new DateTime(checkDate.Year, checkDate.Month, checkDate.Day, hours, minutes, 0);

            var roomName = (string)(sender as RadClock).Header;

            var bookingsService = new BookingsService()
            {
                BookedRooms     = ViewModel.RoomBookings,
                BookedCaterings = ViewModel.CateringsBookings,
                BookedGolfs     = ViewModel.GolfBookings
            };

            var events = bookingsService.GetModelsByRoom(roomName, dateTime).Distinct().ToList();

            if (events.Any())
            {
                this.IsEnabled = false;

                // TODO: If current date has several events ?     //Done
                if (events.Count == 1)
                {
                    var view = new EventDetailsView(new EventModel(events.First()));
                    view.ShowDialog();
                }
                else
                {
                    var view = new EventsBookedView(new ObservableCollection <EventModel>(events.Select(p => new EventModel(p))));
                    view.ShowDialog();
                }
                this.IsEnabled = true;

                //ViewModel.Refresh();
            }
        }
Пример #2
0
        private void RoomClock_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var checkDate = ViewModel.SelectedDate;

            var time = e.AddedItems[0].ToString();
            int hours = Convert.ToInt32(time.Substring(0, 2));
            int minutes = Convert.ToInt32(time.Substring(3, 2));

            var dateTime = new DateTime(checkDate.Year, checkDate.Month, checkDate.Day, hours, minutes, 0);

            var roomName = (string)(sender as RadClock).Header;

            var bookingsService = new BookingsService()
            {
                BookedRooms = ViewModel.RoomBookings,
                BookedCaterings = ViewModel.CateringsBookings,
                BookedGolfs = ViewModel.GolfBookings
            };

            var events = bookingsService.GetModelsByRoom(roomName, dateTime).Distinct().ToList();

            if (events.Any())
            {
                this.IsEnabled = false;

                // TODO: If current date has several events ?     //Done
                if (events.Count == 1)
                {
                    var view = new EventDetailsView(new EventModel(events.First()));
                    view.ShowDialog();
                }
                else
                {
                    var view = new EventsBookedView(new ObservableCollection<EventModel>(events.Select(p => new EventModel(p))));
                    view.ShowDialog();
                }
                this.IsEnabled = true;

                //ViewModel.Refresh();
            }
        }