/// <summary>
        /// The get data for equip search.
        /// </summary>
        public async void GetDataForEquipSearch()
        {
            // Get list condition to search.
            var listConditionSearch = new ObservableCollection<ItemComboBox>
                                           {
                                               new ItemComboBox
                                                   {
                                                       Name = "All Asset Class", ItemId = 0, TypeItem = SystemType.AllAssetClass,
                                                   },
                                               new ItemComboBox
                                                   {
                                                       Name = "Category", ItemId = 1, TypeItem = SystemType.Category,
                                                   },
                                               new ItemComboBox
                                                   {
                                                       Name = "Type", ItemId = 2, TypeItem = SystemType.Type,
                                                   },
                                           };
            
            // Get list result search.
            ObservableCollection<ItemComboBox> listCategory = new ObservableCollection<ItemComboBox>(await RegisteredAssetFunction.GetAllCategory());
            ObservableCollection<ItemComboBox> listType = new ObservableCollection<ItemComboBox>(new List<ItemComboBox>
                                                                                                     {
                                                                                                         new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Type }
                                                                                                     });

            listCategory.Insert(0, new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Category });

            var listItemResultSearch = new ObservableCollection<ItemEquipSearch>
                                            {
                                                new ItemEquipSearch
                                                    {
                                                        ListSourceItems = new DynamicCheckComboBoxViewModel { ComboBoxItemList = listCategory, SelectedItem = listCategory.FirstOrDefault(), TypeItem = SystemType.Category, IsEnableComboBox = true },
                                                        Name = "Category",
                                                        ItemType = SystemType.Category,
                                                    },
                                                new ItemEquipSearch
                                                    {
                                                        ListSourceItems = new DynamicCheckComboBoxViewModel { ComboBoxItemList = listType, SelectedItem = listType.FirstOrDefault(), TypeItem = SystemType.Type, IsEnableComboBox = true },
                                                        Name = "Type",
                                                        ItemType = SystemType.Type,
                                                    },
                                            };

            // Create data column for grid result search.
            var listAllItems = new List<EquipSearchRowItem>();
            var dynamicGridResultSearch = new DynamicGridViewModel(typeof(EquipSearchRowItem));
            dynamicGridResultSearch.GridColumns = new List<DynamicColumn>

                                                                                         {
                                                                                             new DynamicColumn { ColumnName = "EquipCategoryName",  Header = "Category", Width = 82, HeaderTextAlignment = TextAlignment.Center, TextAlignment = TextAlignment.Center },
                                                                                             new DynamicColumn { ColumnName = "EquipTypeName", Header = "Type", Width = 82, HeaderTextAlignment = TextAlignment.Center, TextAlignment = TextAlignment.Center },
                                                                                         };
            dynamicGridResultSearch.GridDataRows = listAllItems.ToList<object>();
            dynamicGridResultSearch.IsSetSelectedItem = true;
            dynamicGridResultSearch.SelectedItemChanged = this.SetSelectedSearchResultItem;
            dynamicGridResultSearch.LoadRadGridView();

            if (this.AssetSettingMakeModel != null)
            {
                // Check if IncludeMake is true
                if (this.AssetSettingMakeModel.IncludeMake)
                {
                    // Insert Make to list Condition to Search
                    ItemComboBox itemConditionMake = new ItemComboBox
                                                         {
                                                             Name = "Make",
                                                             ItemId = 3,
                                                             TypeItem = SystemType.Make,
                                                         };
                    listConditionSearch.Add(itemConditionMake);

                    // Insert Make item to list Result Search
                    ObservableCollection<ItemComboBox> listMake = new ObservableCollection<ItemComboBox>(new List<ItemComboBox>
                                                                                                     {
                                                                                                         new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Make }
                                                                                                     });
                    ItemEquipSearch itemEquipMake = new ItemEquipSearch
                                                   {
                                                       ListSourceItems = new DynamicCheckComboBoxViewModel { ComboBoxItemList = listMake, SelectedItem = listMake.FirstOrDefault(), TypeItem = SystemType.Make, IsEnableComboBox = true },
                                                       Name = "Make",
                                                       ItemType = SystemType.Make,
                                                   };

                    listItemResultSearch.Add(itemEquipMake);

                    // Insert Make column to Grid Search result
                    DynamicColumn columnMake = new DynamicColumn
                                                   {
                                                       ColumnName = "EquipMakeName",
                                                       Header = "Make",
                                                       Width = 82,
                                                       HeaderTextAlignment = TextAlignment.Left,
                                                       TextAlignment = TextAlignment.Left
                                                   };

                    dynamicGridResultSearch.GridColumns.Add(columnMake);
                }

                // Check if IncludeModel is true
                if (this.AssetSettingMakeModel.IncludeModel)
                {
                    // Insert Model to list Condition to Search
                    ItemComboBox itemConditionModel = new ItemComboBox
                                                          {
                                                              Name = "Model",
                                                              ItemId = 4,
                                                              TypeItem = SystemType.Model,
                                                          };
                    listConditionSearch.Add(itemConditionModel);

                    // Insert Model item to list Result Search
                    ObservableCollection<ItemComboBox> listModel = new ObservableCollection<ItemComboBox>(new List<ItemComboBox>
                                                                                                     {
                                                                                                         new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Model }
                                                                                                     });
                    ItemEquipSearch itemEquipModel = new ItemEquipSearch
                    {
                        ListSourceItems = new DynamicCheckComboBoxViewModel { ComboBoxItemList = listModel, SelectedItem = listModel.FirstOrDefault(), TypeItem = SystemType.Model, IsEnableComboBox = true },
                        Name = "Model",
                        ItemType = SystemType.Model,
                    };

                    listItemResultSearch.Add(itemEquipModel);

                    // Insert Model column to Grid Search result
                    DynamicColumn columnModel = new DynamicColumn
                    {
                        ColumnName = "EquipModelName",
                        Header = "Model",
                        Width = 82,
                        HeaderTextAlignment = TextAlignment.Left,
                        TextAlignment = TextAlignment.Left
                    };

                    dynamicGridResultSearch.GridColumns.Add(columnModel);
                }
            }

            // Set action when user select on Grid Result Search
            foreach (var item in listItemResultSearch)
            {
                item.ListSourceItems.SelectedItemChanged += this.ResultSearch_SelectedItemChanged;
            }

            if (this.SearchToolViewModel != null)
            {
                this.SearchToolViewModel.GenerateData(listConditionSearch, 0, listItemResultSearch, dynamicGridResultSearch);
            }
        }
        /// <summary>
        /// The selected item changed.
        /// </summary>
        /// <param name="itemComboBox">
        /// The item combo box.
        /// </param>
        private async void ResultSearch_SelectedItemChanged(ItemComboBox itemComboBox)
        {
            ItemEquipSearch itemSearchType = this.SearchToolViewModel.ListItemResultSearch.FirstOrDefault(x => x.ItemType == SystemType.Type);
            ItemEquipSearch itemSearchMake = this.SearchToolViewModel.ListItemResultSearch.FirstOrDefault(x => x.ItemType == SystemType.Make);
            ItemEquipSearch itemSearchModel = this.SearchToolViewModel.ListItemResultSearch.FirstOrDefault(x => x.ItemType == SystemType.Model);

            List<RegisteredAssetFeatureRowItem> listFeatureItems = new List<RegisteredAssetFeatureRowItem>();

            if (itemComboBox != null)
            {
                if (itemSearchType != null)
                {
                    // Generate type items when select category.
                    if (itemComboBox.TypeItem == SystemType.Category)
                    {
                        if (this.IsCheckedOut)
                        {
                            if (this.CurrentSearchResultItem != null && itemComboBox.ItemId != this.CurrentSearchResultItem.EquipCategoryId)
                            {
                                switch (this.CurrentStateStatus)
                                {
                                    case EnumStateAndStatus.ActiveIdle:
                                        if (RegisteredAssetFunction.CheckActiveBookCanChangeWithId(this.RegisterAssetId, itemComboBox.ItemId, SystemType.Category))
                                        {
                                            this.IsChangeBookDepreciation = true;

                                            // Show window to notify if user want to change Category Depreciation Default
                                            ConfirmationWindowView confirm = new ConfirmationWindowView();
                                            ConfirmmationViewModel confirmViewModel = new ConfirmmationViewModel();
                                            confirmViewModel.Content =
                                                "Asset Category depreciation defaults may have changed. Do you wish to update the current Asset’s depreciation settings ?";
                                            confirmViewModel.Title = "Confirm Save - Asset Register";
                                            confirmViewModel.UseOkCancel = false;
                                            confirm.DataContext = confirmViewModel;

                                            confirm.ShowDialog();
                                            if (confirm.DialogResult == false)
                                            {
                                                this.IsChangeBookDepreciation = false;
                                            }
                                        }

                                        break;
                                    case EnumStateAndStatus.ActiveReturned:
                                        if (RegisteredAssetFunction.CheckActiveBookCanChangeWithId(this.RegisterAssetId, itemComboBox.ItemId, SystemType.Category))
                                        {
                                            this.IsChangeBookDepreciation = true;
                                            this.ShowMessageAsync(
                                                "Asset Category depreciation defaults may have changed. Update the current Asset’s depreciation settings if required.",
                                                "Register Asset");
                                        }

                                        break;
                                    case EnumStateAndStatus.ActiveLive:
                                        this.ShowMessageAsync(
                                                "Asset Category depreciation defaults may have changed update the current Asset’s depreciation settings if required.",
                                                "Register Asset");
                                        break;
                                    case EnumStateAndStatus.ActiveReserved:
                                        this.ShowMessageAsync(
                                                "Asset Category depreciation defaults may have changed update the current Asset’s depreciation settings if required.",
                                                "Register Asset");
                                        break;
                                    case EnumStateAndStatus.Terminated:
                                        this.ShowMessageAsync(
                                                "Asset Category depreciation defaults may have changed update the current Asset’s depreciation settings if required.",
                                                "Register Asset");
                                        break;
                                }
                            }
                            else
                            {
                                this.IsChangeBookDepreciation = false;
                            }
                        }

                        if (itemComboBox.ItemId == 0)
                        {
                            itemSearchType.ListSourceItems.ComboBoxItemList = new ObservableCollection<ItemComboBox>
                                                                            {
                                                                               new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Type }
                                                                            };
                            if (itemSearchMake != null)
                            {
                                itemSearchMake.ListSourceItems.ComboBoxItemList = new ObservableCollection<ItemComboBox>
                                                                            {
                                                                                new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Make }
                                                                            };
                                itemSearchMake.ListSourceItems.SetSelectedItem(0);
                            }

                            if (itemSearchModel != null)
                            {
                                itemSearchModel.ListSourceItems.ComboBoxItemList = new ObservableCollection<ItemComboBox>
                                                                            {
                                                                                new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Model }
                                                                            };

                                itemSearchModel.ListSourceItems.SetSelectedItem(0);
                            }
                        }
                        else
                        {
                            itemSearchType.ListSourceItems.ComboBoxItemList = new ObservableCollection<ItemComboBox>(await RegisteredAssetFunction.GetTypeAssignByCategory(itemComboBox.ItemId));
                            itemSearchType.ListSourceItems.ComboBoxItemList.Insert(0, new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Type });

                            // Get Features items for Grid feature
                            listFeatureItems.AddRange((await RegisteredAssetFunction.GetCategoryFeatureItem(itemComboBox.ItemId)).ConvertAll(x => new RegisteredAssetFeatureRowItem
                            {
                                FeatureId = x.FeatureTypeId,
                                FeatureName = x.FeatureName,
                            }));
                        }

                        itemSearchType.ListSourceItems.SetSelectedItem(0);

                        // Update data for grid Feature
                        this.AllRegisteredFeature = new ObservableCollection<RegisteredAssetFeatureRowItem>(listFeatureItems);
                        this.UpdateDataForFeatureGrid();
                    }

                        // Generate make items when select type.
                        if (itemComboBox.TypeItem == SystemType.Type)
                        {
                            if (this.IsCheckedOut)
                            {
                                if (this.CurrentSearchResultItem != null && itemComboBox.ItemId != this.CurrentSearchResultItem.EquipCategoryId)
                                {
                                    switch (this.CurrentStateStatus)
                                    {
                                        case EnumStateAndStatus.ActiveIdle:
                                            if (RegisteredAssetFunction.CheckActiveBookCanChangeWithId(this.RegisterAssetId, itemComboBox.ItemId, SystemType.Type))
                                            {
                                                this.IsChangeBookDepreciation = true;

                                                // Show window to notify if user want to change Category Depreciation Default
                                                ConfirmationWindowView confirm = new ConfirmationWindowView();
                                                ConfirmmationViewModel confirmViewModel = new ConfirmmationViewModel();
                                                confirmViewModel.Content = "Asset Type depreciation defaults may have changed. Do you wish to update the current Asset’s depreciation settings ?";
                                                confirmViewModel.Title = "Confirm Save - Asset Register";
                                                confirmViewModel.UseOkCancel = false;
                                                confirm.DataContext = confirmViewModel;

                                                confirm.ShowDialog();
                                                if (confirm.DialogResult == false)
                                                {
                                                    this.IsChangeBookDepreciation = false;
                                                }
                                            }

                                            break;
                                        case EnumStateAndStatus.ActiveReturned:
                                            if (RegisteredAssetFunction.CheckActiveBookCanChangeWithId(this.RegisterAssetId, itemComboBox.ItemId, SystemType.Type))
                                            {
                                                this.IsChangeBookDepreciation = true;
                                                this.ShowMessageAsync(
                                                    "Asset Type depreciation defaults may have changed. Update the current Asset’s depreciation settings if required.",
                                                    "Register Asset");
                                            }

                                            break;
                                        case EnumStateAndStatus.ActiveLive:
                                            this.ShowMessageAsync(
                                                    "Asset Type depreciation defaults may have changed update the current Asset’s depreciation settings if required.",
                                                    "Register Asset");
                                            break;
                                        case EnumStateAndStatus.ActiveReserved:
                                            this.ShowMessageAsync(
                                                    "Asset Type depreciation defaults may have changed update the current Asset’s depreciation settings if required.",
                                                    "Register Asset");
                                            break;
                                        case EnumStateAndStatus.Terminated:
                                            this.ShowMessageAsync(
                                                    "Asset Type depreciation defaults may have changed update the current Asset’s depreciation settings if required.",
                                                    "Register Asset");
                                            break;
                                    }
                                }
                                else
                                {
                                    this.IsChangeBookDepreciation = false;
                                }
                            }

                            if (itemComboBox.ItemId == 0)
                            {
                                if (itemSearchMake != null)
                                {
                                    itemSearchMake.ListSourceItems.ComboBoxItemList = new ObservableCollection<ItemComboBox>
                                                                           {
                                                                               new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Make }
                                                                           };
                                    itemSearchMake.ListSourceItems.SetSelectedItem(0);
                                }

                                if (itemSearchModel != null)
                                {
                                    itemSearchModel.ListSourceItems.ComboBoxItemList = new ObservableCollection<ItemComboBox>
                                                                           {
                                                                               new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Model }
                                                                           };
                                    itemSearchModel.ListSourceItems.SetSelectedItem(0);
                                }

                                // Remove Features items for Grid feature
                                listFeatureItems.AddRange((await RegisteredAssetFunction.GetTypeFeatureItem(itemComboBox.ItemId)).ConvertAll(x => new RegisteredAssetFeatureRowItem
                                {
                                    FeatureId = x.FeatureTypeId,
                                    FeatureName = x.FeatureName,
                                }));

                                foreach (var item in listFeatureItems)
                                {
                                    this.AllRegisteredFeature.Remove(this.AllRegisteredFeature.FirstOrDefault(x => x.FeatureId == item.FeatureId));
                                }
                            }
                            else
                            {
                                if (itemSearchMake != null)
                                {
                                    itemSearchMake.ListSourceItems.ComboBoxItemList = new ObservableCollection<ItemComboBox>(await RegisteredAssetFunction.GetMakeAssignByType(itemComboBox.ItemId));
                                    itemSearchMake.ListSourceItems.ComboBoxItemList.Insert(0, new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Make });
                                    itemSearchMake.ListSourceItems.SetSelectedItem(0);
                                }

                                // Get Features items for Grid feature
                                listFeatureItems.AddRange((await RegisteredAssetFunction.GetTypeFeatureItem(itemComboBox.ItemId)).ConvertAll(x => new RegisteredAssetFeatureRowItem
                                {
                                    FeatureId = x.FeatureTypeId,
                                    FeatureName = x.FeatureName,
                                }));

                                foreach (var item in listFeatureItems)
                                {
                                    this.AllRegisteredFeature.Add(item);
                                }

                                // Distinct data
                                this.AllRegisteredFeature = new ObservableCollection<RegisteredAssetFeatureRowItem>(this.AllRegisteredFeature.GroupBy(x => x.FeatureName).Select(x => x.First()).ToList());
                            }

                            // Update data for grid Feature
                            this.UpdateDataForFeatureGrid();
                    }

                    if (itemSearchModel != null)
                    {
                        // Generate model items when select make.
                        if (itemComboBox.TypeItem == SystemType.Make)
                        {
                            if (itemComboBox.ItemId == 0)
                            {
                                itemSearchModel.ListSourceItems.ComboBoxItemList = new ObservableCollection<ItemComboBox>
                                                                                {
                                                                                    new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Model }
                                                                                };
                            }
                            else
                            {
                                itemSearchModel.ListSourceItems.ComboBoxItemList = new ObservableCollection<ItemComboBox>(await RegisteredAssetFunction.GetModelAssignByMake(itemComboBox.ItemId));
                                itemSearchModel.ListSourceItems.ComboBoxItemList.Insert(0, new ItemComboBox { ItemId = 0, Name = "<None>", TypeItem = SystemType.Model });
                            }

                            itemSearchModel.ListSourceItems.SetSelectedItem(0);
                        }
                    }
                }
            }
        }
 /// <summary>
 /// The set selected item.
 /// </summary>
 /// <param name="itemId">
 /// The item Id.
 /// </param>
 public void SetSelectedItem(int itemId)
 {
     this._selectedItem = this.ComboBoxItemList.FirstOrDefault(x => x.ItemId == itemId);
     if (this._selectedItem == null)
     {
         this._selectedItem = this.ComboBoxItemList.FirstOrDefault();
     }
     this.OnPropertyChanged("SelectedItem");
 }