public ResultViewModel <IEnumerable <ManageCategoryViewModel> > Search(int SortBy, int SearchBy, int SearchIn, string SearchText, int PageIndex, int PageSize)
        {
            ResultViewModel <IEnumerable <ManageCategoryViewModel> > result
                = new ResultViewModel <IEnumerable <ManageCategoryViewModel> >();
            int count = 0;

            try
            {
                if (SearchIn == 1)//mainCategory
                {
                    if (SearchBy == 0)
                    {
                        var searshResult = mainCategoryService.GetAll(out count, SortBy, PageIndex, PageSize).Select(i => i.ToManageCategoryViewModel());
                        result.Data = searshResult;
                    }
                    else if (SearchBy == 1)//SearchByParent
                    {
                        var searshResult = mainCategoryService.GetAll(out count, SortBy, PageIndex, PageSize).
                                           Select(i => i.ToManageCategoryViewModel());

                        result.Data = searshResult;
                    }
                    else if (SearchBy == 2) //searchbychild
                    {
                        var searshResult = mainCategoryService.SearchByChilds(out count, 0, SearchText, PageIndex, PageSize).
                                           Select(i => i.ToManageCategoryViewModel());

                        result.Data = searshResult;
                    }
                    else if (SearchBy == 3)//SearchByName
                    {
                        var searshResult = mainCategoryService.SearchByName(out count, 0, SearchText, PageIndex, PageSize)
                                           .Select(i => i.ToManageCategoryViewModel());

                        result.Data = searshResult;
                    }
                    else if (SearchBy == 4) //SearchByID
                    {
                        int  ID;
                        bool VaildID = int.TryParse(SearchText, out ID);
                        if (VaildID)
                        {
                            var searshResult = mainCategoryService.GetAll(out count, 0, PageIndex, PageSize).Where(i => i.ID == ID)
                                               .Select(i => i.ToManageCategoryViewModel());
                            result.Data = searshResult;
                        }
                    }
                }
                else if (SearchIn == 2)//SubCategory
                {
                    if (SearchBy == 0)
                    {
                        var searshResult = subCategoryService.GetAll(out count, SortBy, PageIndex, PageSize)
                                           .Select(i => i.ToManageCategoryViewModel());

                        result.Data = searshResult;
                    }
                    else if (SearchBy == 1)
                    {
                        var searshResult = subCategoryService.SearchByName(out count, SortBy, SearchText, PageIndex, PageSize)
                                           .Select(i => i.ToManageCategoryViewModel());

                        result.Data = searshResult;
                    }
                    else if (SearchBy == 2)
                    {
                        var searshResult = subCategoryService.SearchByChilds(out count, SortBy, SearchText, PageIndex, PageSize)
                                           .Select(i => i.ToManageCategoryViewModel());

                        result.Data = searshResult;
                    }
                    else if (SearchBy == 3)
                    {
                        var searshResult = subCategoryService.SearchByName(out count, SortBy, SearchText, PageIndex, PageSize).
                                           Select(i => i.ToManageCategoryViewModel());

                        result.Data = searshResult;
                    }
                    else if (SearchBy == 4)
                    {
                        int  ID;
                        bool VaildID = int.TryParse(SearchText, out ID);
                        if (VaildID)
                        {
                            var searshResult = subCategoryService.SeachByID(ID).
                                               Select(i => i.ToManageCategoryViewModel());


                            result.Data = searshResult;
                        }
                    }
                }
                else if (SearchIn == 3)//Track
                {
                    if (SearchBy == 0)
                    {
                        var searshResult = trackService.GetAll(out count, SortBy, PageIndex, PageSize).
                                           Select(i => i.ToManageCategoryViewModel());

                        result.Data = searshResult;
                    }
                    else if (SearchBy == 1)
                    {
                        var searshResult = trackService.SearchByParentName(out count, SortBy, SearchText, PageIndex, PageSize).
                                           Select(i => i.ToManageCategoryViewModel());

                        result.Data = searshResult;
                    }
                    else if (SearchBy == 2)
                    {
                        var searshResult = trackService.SearchByChilds(out count, SortBy, SearchText, PageIndex, PageSize).
                                           Select(i => i.ToManageCategoryViewModel());

                        result.Data = searshResult;
                    }
                    else if (SearchBy == 3)
                    {
                        var searshResult = trackService.SearchByName(out count, SortBy, SearchText, PageIndex, PageSize).
                                           Select(i => i.ToManageCategoryViewModel());

                        result.Data = searshResult;
                    }
                    else if (SearchBy == 4)
                    {
                        int  ID;
                        bool VaildID = int.TryParse(SearchText, out ID);
                        if (VaildID)
                        {
                            var searshResult = trackService.SeachByID(ID).
                                               Select(i => i.ToManageCategoryViewModel());

                            result.Data = searshResult;
                        }
                    }
                }
                else if (SearchIn == 4)//Course
                {
                    if (SearchBy == 0)
                    {
                        var searshResult = courseService.GetAll(out count, SortBy, PageIndex, PageSize).
                                           Select(i => i.ToManageCategoryViewModel());

                        result.Data = searshResult;
                    }
                    else if (SearchBy == 1)
                    {
                        var searshResult = courseService.SearchByParentName(out count, SortBy, SearchText, PageIndex, PageSize).
                                           Select(i => i.ToManageCategoryViewModel());
                        result.Data = searshResult;
                    }
                    else if (SearchBy == 2)
                    {
                        result.Data = new List <ManageCategoryViewModel>();
                    }
                    else if (SearchBy == 3)
                    {
                        var searshResult = courseService.SearchByName(out count, SortBy, SearchText, PageIndex, PageSize).
                                           Select(i => i.ToManageCategoryViewModel());

                        result.Data = searshResult;
                    }
                    else if (SearchBy == 4)
                    {
                        int  ID;
                        bool VaildID = int.TryParse(SearchText, out ID);
                        if (VaildID)
                        {
                            var searshResult = courseService.SeachByID(ID).
                                               Select(i => i.ToManageCategoryViewModel());

                            result.Data = searshResult;
                        }
                    }
                }

                else
                {
                    List <ManageCategoryViewModel> res = new List <ManageCategoryViewModel>();
                    var searshResult = new ManageCategoryViewModel()
                    {
                        ID     = 1,
                        Name   = "Main Category Parent",
                        Childs = mainCategoryService.GetAll(out count, SortBy, PageIndex, PageSize).Select(i => i.Name).ToList(),
                        Parent = ""
                    };
                    res.Add(searshResult);

                    result.Data = res;
                }
                result.Count = count;
                if (SearchIn == 0)
                {
                    count = 0;
                }

                result.Successed = true;
            }
            catch (Exception ex)
            {
                result.Successed = false;
                result.Message   = "Something Went Wrong !!";
            }

            return(result);
        }