Beispiel #1
0
 public BookingEntity(Booking booking)
 {
     _pcs           = new PropertyChangeSupport(this);
     _booking       = booking;
     _clientEntity  = new ClientEntity(_booking.Client);
     _paymentEntity = new PaymentEntity(booking);
     _datesEntity   = new DateRangeEntity(_booking.Dates);
     _discountedOptionChoiceEntity = new OptionChoiceEntity(_booking, _booking.DiscountedOptionChoice);
     _optionDiscountEntity         = new DiscountEntity(_booking.OptionDiscount);
 }
Beispiel #2
0
 public BookingEntity(Booking booking)
 {
     _pcs = new PropertyChangeSupport(this);
     _booking = booking;
     _clientEntity = new ClientEntity(_booking.Client);
     _paymentEntity = new PaymentEntity(booking);
     _datesEntity = new DateRangeEntity(_booking.Dates);
     _discountedOptionChoiceEntity = new OptionChoiceEntity(_booking, _booking.DiscountedOptionChoice);
     _optionDiscountEntity = new DiscountEntity(_booking.OptionDiscount);
 }
Beispiel #3
0
        private static void _setAvailableOptionChoiceEntities(Booking booking, DateRange dates, OptionsViewModel newInstance, List<Option> availableOptions)
        {
            foreach (Option opt in availableOptions)
            {
                OptionChoice optChoice = new OptionChoice
                {
                    Option = opt,
                    TakenDates = (DateRange)((ICloneable)dates).Clone()
                };
                optChoice.TakenDates.Start = optChoice.TakenDates.Start.Date;

                if (optChoice.Option.Id == 8)
                {
                    optChoice.TakenDates.Start = optChoice.TakenDates.Start.AddDays(1.0d);
                }

                OptionChoiceEntity optChoiceEntity = new OptionChoiceEntity(booking, optChoice);
                newInstance._availableOptionChoiceEntities.Add(optChoiceEntity);
            }
        }
Beispiel #4
0
 private void _updateOptionChoiceEntities(Booking booking)
 {
     foreach (OptionChoice optChoiceEntity in booking.OptionChoices)
     {
         OptionChoiceEntity optCEntity = new OptionChoiceEntity(booking, optChoiceEntity);
         _optionChoiceEntities.Add(optCEntity);
     }
 }
 public OptionChoiceEntityChange(OptionChangeKind kind, OptionChoiceEntity optChoiceEntity)
 {
     Kind = kind;
     OptionChoiceEntity = optChoiceEntity;
 }
Beispiel #6
0
        private void _checkCapacityWithBabies(OptionChoiceEntity optChoiceEntity)
        {
            bool previouslyHadBabyRoom = hasAvailableBabyRoom();

            bool hasBabyRoom = hasAvailableBabyRoom();

            if (_parameters.BabiesCount > 0 && optChoiceEntity.Taken && previouslyHadBabyRoom)
            {

                if (!hasBabyRoom)
                {
                    MessageReceived?.Invoke(null, $"#Aucune chambre avec lit bébé ne possède l'option {optChoiceEntity.Description}!");
                }
                else
                {
                    MessageReceived?.Invoke(null, null);
                }
            }

            else if (_parameters.BabiesCount > 0 && hasBabyRoom && !previouslyHadBabyRoom)
            {
                MessageReceived?.Invoke(null, null);
            }
        }
Beispiel #7
0
        private void _updateDates(OptionChoiceEntityChange optChoiceEntityChange, OptionChoiceEntity optChoiceEntity)
        {
            if (optChoiceEntityChange.Kind == OptionChangeKind.Taken && optChoiceEntity.Taken)
            {
                DateRange dateRange = (DateRange)((ICloneable)_booking.Dates).Clone();
                optChoiceEntity.TakenStart = dateRange.Start;
                optChoiceEntity.TakenEnd = dateRange.End;

                if (optChoiceEntity.OptionChoice.Option.Id == 8)
                {
                    optChoiceEntity.TakenStart = dateRange.Start.Date.AddDays(1.0d);
                }
            }
        }
Beispiel #8
0
        private void _updateOptionChoices(OptionChoiceEntityChange optChoiceEntityChange, OptionChoiceEntity optChoiceEntity, int optChoiceIndex)
        {
            if (optChoiceEntity.Taken && optChoiceEntityChange.Kind == OptionChangeKind.Taken)
            {
                if (optChoiceIndex != -1)
                {
                    _booking.OptionChoices.RemoveAt(optChoiceIndex);
                }
                _booking.OptionChoices.Add(optChoiceEntity.OptionChoice);
            }


            else if (!optChoiceEntity.Taken && optChoiceEntityChange.Kind == OptionChangeKind.Taken && optChoiceIndex != -1)
            {
                _booking.OptionChoices.Remove(optChoiceEntity.OptionChoice);
            }
        }
        public void Update(OptionChoiceEntity optChoiceEntity)
        {
            Predicate<Room> missChoosenOpt = room => room.Options.FindIndex(opt => opt.Id == optChoiceEntity.OptionChoice.Option.Id) == -1;

            if (optChoiceEntity.Taken)
            {
                for(int i=_availableRooms.Count -1; i>=0; i--)
                {
                    if(missChoosenOpt(_availableRooms[i]))
                    {
                        _filteredRooms.Add(_availableRooms[i]);
                        _availableRoomCounts[_availableRooms[i].Kind]--;
                        _availableRooms.RemoveAt(i);
                    }
                }


                for (int i = _availableRoomChoiceEntities.Count - 1; i >= 0; i--)
                {
                    RoomKind roomKind = _availableRoomChoiceEntities[i].RoomKind;
                    if (_availableRoomCounts[roomKind] == 0)
                    {
                        _availableRoomChoiceEntities.RemoveAt(i);
                    }
                    else
                    {
                        _availableRoomChoiceEntities[i].MaxAvailable = _availableRoomCounts[roomKind];
                    }
                }
            } else
            {
                HashSet<RoomKind> newlyAvailableRoomKinds = new HashSet<RoomKind>();
                HashSet<RoomKind> extraRoomAvailableKinds = new HashSet<RoomKind>();

                for (int i=_filteredRooms.Count -1; i>=0; i--)
                {
                    if(missChoosenOpt(_filteredRooms[i]))
                    {
                        _availableRooms.Add(_filteredRooms[i]);
                        _availableRoomCounts[_filteredRooms[i].Kind]++;
                        if (_availableRoomCounts[_filteredRooms[i].Kind] == 1)
                        {
                            newlyAvailableRoomKinds.Add(_filteredRooms[i].Kind);
                        } else
                        {
                            extraRoomAvailableKinds.Add(_filteredRooms[i].Kind);
                        }
                        _filteredRooms.RemoveAt(i);
                    }
                }

                foreach(RoomKind kind in newlyAvailableRoomKinds)
                {
                    RoomChoiceEntity roomChoiceEntity = new Entities.RoomChoiceEntity(kind, _availableRoomCounts[kind], 0);
                    _availableRoomChoiceEntities.Add(roomChoiceEntity);
                }

                foreach(RoomKind kind in extraRoomAvailableKinds)
                {
                    foreach(RoomChoiceEntity roomChoiceEntity in _availableRoomChoiceEntities)
                    {
                        if(roomChoiceEntity.RoomKind.Equals(kind))
                        {
                            roomChoiceEntity.MaxAvailable = _availableRoomCounts[kind];
                            break;
                        }
                    }
                }
            }
        }