private ObservableCollection<ItemCollateralClassViewModel> GetListMultiItemAppendTo(PPSRCollateralClass item) { ObservableCollection<AssetCollateralItemDetail> listContractFeatures = this.GetContractFeatures(); ObservableCollection<AssetCollateralItemDetail> listCustomeFields = this.GetCustomFields(); ObservableCollection<ItemCollateralClassViewModel> temp = new ObservableCollection<ItemCollateralClassViewModel> { new ItemCollateralClassViewModel { IsShowUp = true, CollateralFieldID = Asset.CollateralFieldID.AppendedToContractMappedField, Header = "Contract Mapped Field : ", ItemType = 631, ListComboBox = listCustomeFields, SelectComboBox = listCustomeFields != null && listCustomeFields.FirstOrDefault(x => x.ItemId == item.MappedFieldID) != null ? listCustomeFields.FirstOrDefault(x => x.ItemId == item.MappedFieldID) : listCustomeFields.FirstOrDefault(x => x.ItemId == -1) }, new ItemCollateralClassViewModel { IsShowUp = true, CollateralFieldID = Asset.CollateralFieldID.AppendedToQuoteMappedField, Header = "Quote Mapped Field : ", ItemType = 631, ListComboBox = listCustomeFields, SelectComboBox = listCustomeFields != null && listCustomeFields.FirstOrDefault(x => x.ItemId == item.QuoteMappedFieldID) != null && listCustomeFields.FirstOrDefault(x => x.ItemId == item.QuoteMappedFieldID) != null ? listCustomeFields.FirstOrDefault(x => x.ItemId == item.QuoteMappedFieldID) : listCustomeFields.FirstOrDefault(x => x.ItemId == -1) }, new ItemCollateralClassViewModel { IsShowUp = true, CollateralFieldID = Asset.CollateralFieldID.AppendedToMappedField, Header = "Mapped Field : ", ItemType = 630, ListComboBox = listContractFeatures, SelectComboBox = listContractFeatures != null && listContractFeatures.FirstOrDefault(x => x.ItemId == item.MappedFieldID) != null ? listContractFeatures.FirstOrDefault(x => x.ItemId == item.MappedFieldID) : listContractFeatures.FirstOrDefault(x => x.ItemId == -1) }, }; return temp; }
/// <summary> /// The set value for asset collateral detail. /// </summary> /// <param name="value"> /// The value. /// </param> private void SetValueForAssetCollateralDetail(PPSRCollateralClass value) { this.AssetCollateralDetailViewModel.CollateralName = value.Description; }
/// <summary> /// The populate collateral classes. /// </summary> /// <param name="selectedCollateral"> /// The selected collateral. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> // ReSharper disable once CSharpWarnings::CS1998 public async Task PopulateCollateralClasses(PPSRCollateralClass selectedCollateral) { if (selectedCollateral != null) { ObservableCollection<AssetCollateralItemDetail> listRegs = this.GetListRegistrationEndDate(); ObservableCollection<AssetCollateralItemDetail> listMappedTos = this.GetListMappedTo(this._mappedToSystemConstantIDs); ObservableCollection<AssetCollateralItemDetail> listMotorVehicleRegos = this.GetListMappedTo(this._motorVehicleRegoMappedToSystemConstantIDs); ObservableCollection<AssetCollateralItemDetail> listAircrafts = this.GetListMappedTo(this._aircraftNationalityMappedToSystemConstantIDs); ObservableCollection<AssetCollateralItemDetail> listAircraftsCodeAndRegoMarks = this.GetListMappedTo(this._aircraftNationalityCodeAndRegoMarkSystemConstantIDs); ObservableCollection<AssetCollateralItemDetail> listAircraftManufacturerModels = this.GetListMappedTo(this._aircraftManufacturerModelMappedConstantIDs); ObservableCollection<AssetCollateralItemDetail> listAircraftManufacturerNames = this.GetListMappedTo(this._aircraftManufacturerNameMappedToConstantIDs); ObservableCollection<AssetCollateralItemDetail> listSerials = this.GetListSerialNumberType(selectedCollateral.CollateralClassID); this.ListCollateralDetail = new ObservableCollection<ItemCollateralClassViewModel>(); this.ListCollateralDetail.Add(new ItemCollateralClassViewModel { IsShowUp = true, CollateralFieldID = Asset.CollateralFieldID.RegistrationEndDate, Header = "Registration End Date : ", ListComboBox = listRegs, SelectComboBox = listRegs != null && selectedCollateral.RegoEndDateID != null ? listRegs.FirstOrDefault(x => x.ItemId == selectedCollateral.RegoEndDateID) : listRegs.FirstOrDefault(d => d.ItemId == -1) }); this.ListCollateralDetail.Add(new ItemCollateralClassViewModel { IsShowUp = this.CheckSerialNumberRequired(selectedCollateral.CollateralClassID), CollateralFieldID = Asset.CollateralFieldID.SerialNumberType, Header = "Serial Number Type : ", ListComboBox = listSerials, SelectComboBox = listSerials != null && selectedCollateral.SerialNumberTypeID != null ? listSerials.FirstOrDefault(x => x.ItemId == selectedCollateral.SerialNumberTypeID) : listSerials.FirstOrDefault(d => d.ItemId == -1) }); this.ListCollateralDetail.Add(new ItemCollateralClassViewModel { IsShowUp = this.CheckSerialNumberRequired(selectedCollateral.CollateralClassID), CollateralFieldID = Asset.CollateralFieldID.MappedTo, Header = "Mapped To : ", ListComboBox = listMappedTos, ListMultiItem = this.GetListMultiItemMappedTo(selectedCollateral), SelectComboBox = listMappedTos != null && selectedCollateral.MappedToID != null ? listMappedTos.FirstOrDefault(x => x.ItemId == selectedCollateral.MappedToID) : listMappedTos.FirstOrDefault(d => d.ItemId == -1) }); this.ListCollateralDetail.Add(new ItemCollateralClassViewModel { IsShowUp = !this.CheckSerialNumberRequired(selectedCollateral.CollateralClassID), CollateralFieldID = Asset.CollateralFieldID.AppendedTo, Header = "Append To Description : ", ListComboBox = listMappedTos, ListMultiItem = this.GetListMultiItemAppendTo(selectedCollateral), SelectComboBox = listMappedTos != null && selectedCollateral.MappedToID != null ? listMappedTos.FirstOrDefault(x => x.ItemId == selectedCollateral.MappedToID) : listMappedTos.FirstOrDefault(d => d.ItemId == -1) }); this.ListCollateralDetail.Add(new ItemCollateralClassViewModel { IsShowUp = selectedCollateral.CollateralClassID == 626, CollateralFieldID = Asset.CollateralFieldID.MotorVehicleRegoMappedTo, Header = "Motor Vehicle Rego Mapped To : ", ListComboBox = listMotorVehicleRegos, ListMultiItem = this.GetListMultiItemMotorVehicleRegoMappedTo(selectedCollateral.MotorVehicleRego), SelectComboBox = listMotorVehicleRegos != null && selectedCollateral.MotorVehicleRego != null && selectedCollateral.MotorVehicleRego.RegoMappedTo != null ? listMotorVehicleRegos.FirstOrDefault(x => x.ItemId == selectedCollateral.MotorVehicleRego.RegoMappedTo) : listMotorVehicleRegos.FirstOrDefault(d => d.ItemId == -1) }); this.ListCollateralDetail.Add(new ItemCollateralClassViewModel { IsShowUp = this._listShowUp.Contains(selectedCollateral.CollateralClassID), CollateralFieldID = Asset.CollateralFieldID.AircraftNationalityMappedTo, Header = "Aircraft Nationality Mapped To : ", ListComboBox = listAircrafts, ListMultiItem = this.GetListMultiItemAircraftNationalityMappedTo(selectedCollateral.Aircraft), SelectComboBox = listAircrafts != null && selectedCollateral.Aircraft != null && selectedCollateral.Aircraft.NationalityMappedTo != null ? listAircrafts.FirstOrDefault(x => x.ItemId == selectedCollateral.Aircraft.NationalityMappedTo) : listAircrafts.FirstOrDefault(d => d.ItemId == -1) }); this.ListCollateralDetail.Add( new ItemCollateralClassViewModel { IsShowUp = this._listShowUp.Contains( selectedCollateral.CollateralClassID), CollateralFieldID = Asset.CollateralFieldID.AircraftNationalityCodeRegoMarkMappedTo, Header = "Aircraft Nationality Code and Rego Mark Mapped To : ", ListComboBox = listAircraftsCodeAndRegoMarks, ListMultiItem = this .GetListMultiItemAircraftNationalityCodeAndRegoMarkMappedTo (selectedCollateral.Aircraft), SelectComboBox = listAircraftsCodeAndRegoMarks != null && selectedCollateral.Aircraft != null && selectedCollateral.Aircraft.NationalityCodeAndRegoMarkMappedTo != null ? listAircraftsCodeAndRegoMarks.FirstOrDefault( x => x.ItemId == selectedCollateral.Aircraft .NationalityCodeAndRegoMarkMappedTo) : listAircraftsCodeAndRegoMarks.FirstOrDefault(d => d.ItemId == -1) }); this.ListCollateralDetail.Add(new ItemCollateralClassViewModel { IsShowUp = this._listShowUp.Contains(selectedCollateral.CollateralClassID), CollateralFieldID = Asset.CollateralFieldID.AircraftManufacturerModelMappedTo, Header = "Aircraft Manufacturer’s Model Mapped To : ", ListComboBox = listAircraftManufacturerModels, ListMultiItem = this.GetListMultiItemAircraftManufacturerModelMappedTo(selectedCollateral.Aircraft), SelectComboBox = listAircraftManufacturerModels != null && selectedCollateral.Aircraft != null && selectedCollateral.Aircraft.ManufacturerModelMappedTo != null ? listAircraftManufacturerModels.FirstOrDefault(x => x.ItemId == selectedCollateral.Aircraft.ManufacturerModelMappedTo) : listAircraftManufacturerModels.FirstOrDefault(d => d.ItemId == -1) }); this.ListCollateralDetail.Add( new ItemCollateralClassViewModel { IsShowUp = this._listShowUp.Contains( selectedCollateral.CollateralClassID), CollateralFieldID = Asset.CollateralFieldID.AircraftManufacturerNameMappedTo, Header = "Aircraft Manufacturer’s Name Mapped To : ", ListComboBox = listAircraftManufacturerNames, ListMultiItem = this.GetListMultiItemAircraftManufacturerNameMappedTo( selectedCollateral.Aircraft), SelectComboBox = listAircraftManufacturerNames != null && selectedCollateral.Aircraft != null && selectedCollateral.Aircraft != null && selectedCollateral.Aircraft .ManufacturerNameMappedTo != null ? listAircraftManufacturerNames.FirstOrDefault( x => x.ItemId == selectedCollateral.Aircraft .ManufacturerNameMappedTo) : listAircraftManufacturerNames.FirstOrDefault(d => d.ItemId == -1) }); } }
/// <summary> /// The set selected collateral classes. /// </summary> /// <param name="value"> /// The value. /// </param> private async void SetSelectedCollateralClasses(PPSRCollateralClass value) { bool canProceed = true; if (this.IsCheckedOut && this.IsChanged) { ConfirmationWindowView confirm = new ConfirmationWindowView(); ConfirmmationViewModel confirmViewModel = new ConfirmmationViewModel(); confirmViewModel.Content = "Changes have not been saved. Click OK to proceed without saving changes."; confirmViewModel.Title = "Confirm Save - Asset Collateral"; confirm.DataContext = confirmViewModel; confirm.ShowDialog(); if (confirm.DialogResult == false) { canProceed = false; } else { this.IsChanged = false; } } if (canProceed) { // Raise event to change style for hyperlink when select another record. this.ValidateNotError(); this.IsChanged = false; this.IsCheckedOut = false; this.SetIsCheckedOut(); // Just do UnLockAsync if not in mode Add. if (value != null) { if (this.SelectedCollateral != null) { await this.UnLockBulkUpdateAssetFeaturesAsync(); } } this.SetField(ref this._selectedCollateral, value, () => this.SelectedCollateral); if (value != null) { this.SetValueForMappedTo(); await this.OnStepAsync(Asset.EnumSteps.SelectedCollateral); } } }