Ejemplo n.º 1
0
        public BookingViewModel(IUnitOfWork unit, IEventAggregator eventAggregator,
                                IBookingCalculate calculationService,
                                ISearchGuestService searchGuestService,
                                IBookingFacade bookingFacade,
                                IRegionManager regionManager)
        {
            _unit = unit;
            _calculationService = calculationService;
            _searchGuestService = searchGuestService;
            _bookingFacade      = bookingFacade;
            _eventAggregator    = eventAggregator;

            _regionManager = regionManager;

            GuestResults = new ObservableCollection <Guest>();
            SearchRooms  = new SearchWrapper();
            Guest        = new GuestWrapper();

            SearchCommand = new DelegateCommand(SearchExecute, CanSearchExecute).ObservesCanExecute(() => SearchRooms.IsEnabled);
            BookCommand   = new DelegateCommand <object>(BookExecute, CanBookExecute).ObservesCanExecute(() => IsGuestFormValid);

            _eventAggregator.GetEvent <LoadEvent>().Subscribe(OnLoadEvent);

            Calculation.GetInstance().StayTypeChanged             += BookingViewModel_StayTypeChanged;
            SelectedRoomChange.GetInstance().RoomSelectionChanged += BookingViewModel_RoomSelectionChanged;
            SelectedGuestEvent.GetInstance().SelectedGuestChanged += OnSelectedGuestChange;

            SearchRooms.StateChanged += SearchRooms_StateChanged;
            Guest.StateChanged       += Guest_StateChanged;
        }
Ejemplo n.º 2
0
 public void OnNavigatedFrom(NavigationContext navigationContext)
 {
     Guest.StateChanged -= Guest_StateChanged;
     Calculation.GetInstance().StayTypeChanged             -= BookingViewModel_StayTypeChanged;
     SelectedRoomChange.GetInstance().RoomSelectionChanged -= BookingViewModel_RoomSelectionChanged;
     SearchRooms.StateChanged -= SearchRooms_StateChanged;
     SelectedGuestEvent.GetInstance().SelectedGuestChanged -= OnSelectedGuestChange;
 }