private async void _parameters_defined(object sender, BookingParametersViewModel bookingParametersVM) { try { ParametersValidated = true; DateRange dateRange = new DateRange { Start = _parameters.Start, End = _parameters.End }; Options = await OptionsViewModel.CreateAsync(_booking, dateRange); RoomChoices = await RoomsChoiceViewModel.CreateAsync(dateRange); RoomChoices.AvailableRoomChoiceEntitiesView.Filter = _mustShowRoomChoice; _newClientCommand.ChangeCanExecute(); _searchClientCommand.ChangeCanExecute(); _validateBookingCommand.ChangeCanExecute(); } catch (Exception ex) { Logger.Log(ex); } }
public static async Task <RoomsChoiceViewModel> CreateAsync(DateRange dates) { RoomsChoiceViewModel newInstance = new RoomsChoiceViewModel(); newInstance._availableRooms = await RoomRepository.GetAvailablesBetweenAsync(dates); int i = 0; foreach (Room room in newInstance._availableRooms) { if (!newInstance._availableRoomCounts.ContainsKey(room.Kind)) { newInstance._availableRoomCounts.Add(room.Kind, 1); RoomChoiceEntity roomChoice = new RoomChoiceEntity(room.Kind, 0, 0); newInstance._availableRoomChoiceEntities.Add(roomChoice); i++; } else { newInstance._availableRoomCounts[room.Kind]++; } } foreach (RoomChoiceEntity roomChoice in newInstance._availableRoomChoiceEntities) { roomChoice.MaxAvailable = newInstance._availableRoomCounts[roomChoice.RoomKind]; } return(newInstance); }
private async Task _validateParameters() { try { _parametersValidated = true; bool newClientCanExecute = _newClientCommand.CanExecute(null); bool searchClientCanExecute = _searchClientCommand.CanExecute(null); bool validateBookingCanExecute = _validateBookingCommand.CanExecute(null); _handleCommandStates(newClientCanExecute, searchClientCanExecute, validateBookingCanExecute); DateRange dateRange = new DateRange { Start = _parameters.Start, End = _parameters.End }; Options = await OptionsViewModel.CreateAsync(_booking, dateRange); RoomChoices = await RoomsChoiceViewModel.CreateAsync(dateRange); RoomChoices.AvailableRoomChoiceEntitiesView.Filter = _mustShowRoomChoice; _updateOptionChoicesEntities(); Dictionary <RoomKind, int> takenRoomKind = new Dictionary <RoomKind, int>(); _countTakenRooms(takenRoomKind); _setRoomChoiceEntitiesCounts(takenRoomKind); } catch (Exception ex) { Logger.Log(ex); } }
public static async Task<RoomsChoiceViewModel> CreateAsync(DateRange dates) { RoomsChoiceViewModel newInstance = new RoomsChoiceViewModel(); newInstance._availableRooms = await RoomRepository.GetAvailablesBetweenAsync(dates); int i = 0; foreach (Room room in newInstance._availableRooms) { if (!newInstance._availableRoomCounts.ContainsKey(room.Kind)) { newInstance._availableRoomCounts.Add(room.Kind, 1); RoomChoiceEntity roomChoice = new RoomChoiceEntity(room.Kind, 0, 0); newInstance._availableRoomChoiceEntities.Add(roomChoice); i++; } else { newInstance._availableRoomCounts[room.Kind]++; } } foreach (RoomChoiceEntity roomChoice in newInstance._availableRoomChoiceEntities) { roomChoice.MaxAvailable = newInstance._availableRoomCounts[roomChoice.RoomKind]; } return newInstance; }