Exemplo n.º 1
0
        private async Task _editBooking(SumUpViewModel sumUpVM)
        {
            try
            {
                LinkedListNode <INavigableViewModel> prevNode = _navigation.Find(sumUpVM);
                BookingViewModel bookingVM = await BookingViewModel.LoadAsync(_navigation, _booking, prevNode);

                NextCalled?.Invoke(this, sumUpVM);
            } catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }
Exemplo n.º 2
0
        private async Task _validateBooking(BookingViewModel bookingVM)
        {
            try
            {
                await _roomChoices.AssignRoomsCommand.ExecuteAsync(_booking);

                LinkedListNode <INavigableViewModel> prevNode = _navigation.Find(this);
                SumUpViewModel sumUpVM = new SumUpViewModel(_navigation, _booking, prevNode);
                NextCalled?.Invoke(null, this);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }
Exemplo n.º 3
0
        private async Task _newClient(BookingViewModel bookingVM)
        {
            try
            {
                LinkedListNode <INavigableViewModel> prevNode = _navigation.Find(bookingVM);
                ClientViewModel clientVM = new ClientViewModel(_navigation, _clientEntity, prevNode);
                await _roomChoices.AssignRoomsCommand.ExecuteAsync(_booking);

                bool success = _checkRoomCapacityWithBabies(bookingVM);
                if (success)
                {
                    NextCalled?.Invoke(null, bookingVM);
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }
Exemplo n.º 4
0
        private async Task _searchClient(BookingViewModel bookingVM)
        {
            try
            {
                List <Client> clients = await ClientRepository.GetAllClients();

                List <ClientEntity> clientEntities = new List <ClientEntity>(clients.Count);
                foreach (Client client in clients)
                {
                    ClientEntity clientEntity = new ClientEntity(client);
                    clientEntities.Add(clientEntity);
                }
                SearchClientsViewModel searchClientVM = new SearchClientsViewModel(clientEntities);
                searchClientVM.ClientSelected += _searchClient_clientSelected;
                ViewDriverProvider.ViewDriver.ShowView <SearchClientsViewModel>(searchClientVM);
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }
Exemplo n.º 5
0
        private bool _checkRoomCapacityWithBabies(BookingViewModel bookingVM)
        {
            bool success = false;

            if (_clientEntity.Bookings != null && _clientEntity.Bookings.Count > 0)
            {
                int babiesRooms, totalAdultCapacity;
                _countBabiesAndAdultsCapacity(out babiesRooms, out totalAdultCapacity);

                if (babiesRooms < _booking.BabiesCount || totalAdultCapacity < _booking.AdultsCount)
                {
                    PromptViewModel insufficientRoomsPromptVM = new PromptViewModel("Erreur",
                                                                                    $"Il n'y a pas assez de chambre pour accueillir {_booking.BabiesCount} bébés et {_booking.AdultsCount} adultes.",
                                                                                    false
                                                                                    );
                    ViewDriverProvider.ViewDriver.ShowView <PromptViewModel>(insufficientRoomsPromptVM);
                }
                else
                {
                    success = true;
                }
            }
            return(success);
        }
Exemplo n.º 6
0
        private void _addBooking(object ignore)
        {
            try
            {
                Logger.Log("=Ajout d'une réservation=");
                Booking booking = new Booking();
                booking.CreationDate = DateTime.Now;
                booking.Dates.Start  = DateTime.Now;
                booking.Dates.End    = DateTime.Now.AddDays(1.0);

                Logger.Log("Ajout d'une réservation: chargement de la fiche de réservation");
                BookingViewModel bookingVM = new BookingViewModel(_navigation, booking);
                _navigation = bookingVM.Navigation;
                _currentEntities.Add(bookingVM);
                _currentEntitiesView.MoveCurrentToPosition(_currentEntities.Count - 1);
                bookingVM.NextCalled      += _nextCalled;
                bookingVM.PreviousCalled  += _prevCalled;
                bookingVM.MessageReceived += _messageReceived;
            }
            catch (Exception ex)
            {
                Logger.Log(ex);
            }
        }
Exemplo n.º 7
0
        private void _addBooking(object ignore)
        {
            try
            {
                Logger.Log("=Ajout d'une réservation=");
                Booking booking = new Booking();
                booking.CreationDate = DateTime.Now;
                booking.Dates.Start = DateTime.Now;
                booking.Dates.End = DateTime.Now.AddDays(1.0);

                Logger.Log("Ajout d'une réservation: chargement de la fiche de réservation");
                BookingViewModel bookingVM = new BookingViewModel(_navigation, booking);
                _navigation = bookingVM.Navigation;
                _currentEntities.Add(bookingVM);
                _currentEntitiesView.MoveCurrentToPosition(_currentEntities.Count - 1);
                bookingVM.NextCalled += _nextCalled;
                bookingVM.PreviousCalled += _prevCalled;
                bookingVM.MessageReceived += _messageReceived;
            }
            catch (Exception ex)
            {

                Logger.Log(ex);
            }
        }
Exemplo n.º 8
0
        private async Task _validateBooking(BookingViewModel bookingVM)
        {
            try
            {
                await _roomChoices.AssignRoomsCommand.ExecuteAsync(_booking);

                LinkedListNode<INavigableViewModel> prevNode = _navigation.Find(this);
                SumUpViewModel sumUpVM = new SumUpViewModel(_navigation, _booking, prevNode);
                NextCalled?.Invoke(null, this);
            }
            catch (Exception ex)
            {

                Logger.Log(ex);
            }
        }
Exemplo n.º 9
0
        private async Task _searchClient(BookingViewModel bookingVM)
        {
            try
            {
                List<Client> clients = await ClientRepository.GetAllClients();
                List<ClientEntity> clientEntities = new List<ClientEntity>(clients.Count);
                foreach (Client client in clients)
                {
                    ClientEntity clientEntity = new ClientEntity(client);
                    clientEntities.Add(clientEntity);
                }
                SearchClientsViewModel searchClientVM = new SearchClientsViewModel(clientEntities);
                searchClientVM.ClientSelected += _searchClient_clientSelected;
                ViewDriverProvider.ViewDriver.ShowView<SearchClientsViewModel>(searchClientVM);
            }
            catch (Exception ex)
            {

                Logger.Log(ex);
            }
        }
Exemplo n.º 10
0
        private bool _checkRoomCapacityWithBabies(BookingViewModel bookingVM)
        {
            bool success = false;
            if (_clientEntity.Bookings != null && _clientEntity.Bookings.Count > 0)
            {
                int babiesRooms, totalAdultCapacity;
                _countBabiesAndAdultsCapacity(out babiesRooms, out totalAdultCapacity);

                if (babiesRooms < _booking.BabiesCount || totalAdultCapacity < _booking.AdultsCount)
                {
                    PromptViewModel insufficientRoomsPromptVM = new PromptViewModel("Erreur",
                        $"Il n'y a pas assez de chambre pour accueillir {_booking.BabiesCount} bébés et {_booking.AdultsCount} adultes.",
                        false
                    );
                    ViewDriverProvider.ViewDriver.ShowView<PromptViewModel>(insufficientRoomsPromptVM);
                }
                else
                {
                    success = true;
                }
            }
            return success;
        }
Exemplo n.º 11
0
        private async Task _newClient(BookingViewModel bookingVM)
        {
            try
            {
                LinkedListNode<INavigableViewModel> prevNode = _navigation.Find(bookingVM);
                ClientViewModel clientVM = new ClientViewModel(_navigation, _clientEntity, prevNode);
                await _roomChoices.AssignRoomsCommand.ExecuteAsync(_booking);

                bool success = _checkRoomCapacityWithBabies(bookingVM);
                if (success)
                {
                    NextCalled?.Invoke(null, bookingVM);
                }
            }
            catch (Exception ex)
            {

                Logger.Log(ex);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Loads a BookingViewModel from an existing Booking
        /// </summary>
        /// <param name="navigation">Navigation object used in MainViewWindow to change tab's content</param>
        /// <param name="booking">the existing booking loaded from db</param>
        /// <param name="prevNode">the reviously loaded INavigableViewModel, for use within navigation</param>
        /// <returns></returns>
        public static async Task<BookingViewModel> LoadAsync(LinkedList<INavigableViewModel> navigation, Booking booking, LinkedListNode<INavigableViewModel> prevNode)
        {
            BookingViewModel bookingVM = new BookingViewModel(navigation, booking, prevNode);
            await bookingVM._validateParameters();

            return bookingVM;
        }