public BusinessToBusinesListModel Search(BusinessToBusinessFilter businessToBusinessFilter)
        {
            var country     = string.Join(",", businessToBusinessFilter.Countries);
            var state       = string.Join(",", businessToBusinessFilter.States);
            var city        = string.Join(",", businessToBusinessFilter.Cities);
            var area        = string.Join(",", businessToBusinessFilter.Areas);
            var designation = string.Join(",", businessToBusinessFilter.Designation);
            var categoryId  = string.Join(",", businessToBusinessFilter.BusinessCategoryId);
            var tags        = string.Join(",", businessToBusinessFilter.Tags);
            var categories  = _customerDataManagementContext.B2bcategory.ToList();

            var b2bFilter = _customerDataManagementContext.BusinessToBusiness
                            .FromSql("EXECUTE dm.usp_SearchBusinessToBusiness @p0, @p1,@p2, @p3,@p4, @p5,@p6",
                                     parameters: new[] { country, state, city, area, designation, categoryId, tags }).ToList();

            var b2bSearchResult = b2bFilter.GroupJoin(categories,
                                                      x => x.CategoryId,
                                                      y => y.CategoryId,
                                                      (x, y) => new BusinessToBusinesModel
            {
                Add1           = x.Add1,
                Add2           = x.Add2,
                Area           = x.Area,
                CategoryId     = x.CategoryId,
                City           = x.City,
                CompanyName    = x.CompanyName,
                ContactPerson  = x.ContactPerson,
                Contactperson1 = x.Contactperson1,
                Country        = x.Country,
                Designation    = x.Designation,
                Designation1   = x.Designation1,
                Email          = x.Email,
                Email1         = x.Email1,
                EstYear        = x.EstYear,
                Fax            = x.Fax,
                LandMark       = x.LandMark,
                Mobile1        = x.Mobile1,
                Mobile2        = x.Mobile2,
                MobileNew      = x.MobileNew,
                NoOfEmp        = x.NoOfEmp,
                Phone1         = x.Phone1,
                Phone2         = x.Phone2,
                PhoneNew       = x.PhoneNew,
                Pincode        = x.Pincode,
                State          = x.State,
                Web            = x.Web,
                CategoryName   = y.Any() ? y.FirstOrDefault().Name : string.Empty
            }).ToList();

            BusinessToBusinesListModel businessToBusinesListModel = new BusinessToBusinesListModel
            {
                BusinessToBusiness = b2bSearchResult,
                SearchCount        = b2bSearchResult.Count(),
                Total = _customerDataManagementContext.BusinessToBusiness.Count()
            };

            return(businessToBusinesListModel);
        }
        public IActionResult BusinessToBusinessSearch(CustomerDataSearch business2Business)
        {
            var rootPath = _appSettings.Value.SearchExport;
            int rowRange = _appSettings.Value.RowRange;
            BusinessToBusinessFilter businessToBusinessFilter = new BusinessToBusinessFilter()
            {
                Areas = business2Business.Area.Any() ? business2Business.Area.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray() : null,
                BusinessCategoryId = business2Business.BusinessCategoryId.Any() ? business2Business.BusinessCategoryId.ToArray() : new int[] { },
                Cities             = business2Business.Cities.Any() ? business2Business.Cities.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray() : null,
                Countries          = business2Business.Contries.Any() ? business2Business.Contries.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray() : null,
                Designation        = business2Business.Designation.Any() ? business2Business.Designation.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray() : null,
                States             = business2Business.States.Any() ? business2Business.States.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray() : null,
                Tags = business2Business.Tags.Any() ? business2Business.Tags : new int[] { }
            };
            var businessToBusiness = _filterBusinessToBusiness.Search(businessToBusinessFilter);
            var b2bDashboard       = _prepareB2BDashBoard.Prepare(businessToBusiness);
            var fileName           = _businessToBusinessExport.ExportExcel(businessToBusiness.BusinessToBusiness, rootPath, rowRange);

            b2bDashboard.DownloadLink = fileName;
            return(Json(b2bDashboard));
        }