-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
support
committed
Oct 28, 2023
1 parent
113460c
commit 3587775
Showing
28 changed files
with
689 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 0 additions & 71 deletions
71
src/Web/Grand.Web.Vendor/Areas/Vendor/Views/Product/Partials/CreateOrUpdate.Documents.cshtml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
src/Web/Grand.Web.Vendor/Controllers/SearchController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
using Grand.Business.Core.Interfaces.Catalog.Categories; | ||
using Grand.Business.Core.Interfaces.Catalog.Collections; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Grand.Web.Common.DataSource; | ||
using Grand.Domain.Catalog; | ||
using Grand.Business.Core.Interfaces.Catalog.Brands; | ||
using Grand.Domain.Admin; | ||
using Grand.Web.Vendor.Models.Common; | ||
|
||
namespace Grand.Web.Vendor.Controllers | ||
{ | ||
public class SearchController : BaseVendorController | ||
{ | ||
private readonly ICategoryService _categoryService; | ||
private readonly ICollectionService _collectionService; | ||
private readonly AdminSearchSettings _adminSearchSettings; | ||
private readonly IBrandService _brandService; | ||
|
||
public SearchController(ICategoryService categoryService, | ||
IBrandService brandService, ICollectionService collectionService, | ||
AdminSearchSettings adminSearchSettings) | ||
{ | ||
_categoryService = categoryService; | ||
_brandService = brandService; | ||
_collectionService = collectionService; | ||
_adminSearchSettings = adminSearchSettings; | ||
} | ||
|
||
[HttpGet] | ||
public async Task<IActionResult> Category(string categoryId) | ||
{ | ||
var value = HttpContext.Request.Query["filter[filters][0][value]"].ToString(); | ||
|
||
async Task<IList<SearchModel>> PrepareModel(IEnumerable<Category> categories) | ||
{ | ||
var model = new List<SearchModel>(); | ||
if (!string.IsNullOrEmpty(categoryId)) | ||
{ | ||
var currentCategory = await _categoryService.GetCategoryById(categoryId); | ||
if (currentCategory != null) | ||
{ | ||
model.Add(new SearchModel { | ||
Id = currentCategory.Id, | ||
Name = await _categoryService.GetFormattedBreadCrumb(currentCategory) | ||
}); | ||
} | ||
} | ||
foreach (var item in categories) | ||
{ | ||
if (item.Id != categoryId) | ||
model.Add(new SearchModel { | ||
Id = item.Id, | ||
Name = await _categoryService.GetFormattedBreadCrumb(item) | ||
}); | ||
} | ||
return model; | ||
} | ||
|
||
var categories = await _categoryService.GetAllCategories( | ||
categoryName: value, | ||
pageSize: _adminSearchSettings.CategorySizeLimit); | ||
var gridModel = new DataSourceResult | ||
{ | ||
Data = await PrepareModel(categories) | ||
}; | ||
return Json(gridModel); | ||
} | ||
|
||
[HttpGet] | ||
public async Task<IActionResult> Collection(string collectionId) | ||
{ | ||
var value = HttpContext.Request.Query["filter[filters][0][value]"].ToString(); | ||
|
||
async Task<IList<SearchModel>> PrepareModel(IEnumerable<Collection> collections) | ||
{ | ||
var model = new List<SearchModel>(); | ||
if (!string.IsNullOrEmpty(collectionId)) | ||
{ | ||
var currentCollection = await _collectionService.GetCollectionById(collectionId); | ||
if (currentCollection != null) | ||
{ | ||
model.Add(new SearchModel { | ||
Id = currentCollection.Id, | ||
Name = currentCollection.Name | ||
}); | ||
} | ||
} | ||
foreach (var item in collections) | ||
{ | ||
if (item.Id != collectionId) | ||
model.Add(new SearchModel { | ||
Id = item.Id, | ||
Name = item.Name | ||
}); | ||
} | ||
return model; | ||
} | ||
|
||
var collections = await _collectionService.GetAllCollections( | ||
collectionName: value, | ||
pageSize: _adminSearchSettings.CollectionSizeLimit); | ||
|
||
var gridModel = new DataSourceResult | ||
{ | ||
Data = await PrepareModel(collections) | ||
}; | ||
return Json(gridModel); | ||
} | ||
|
||
[HttpGet] | ||
public async Task<IActionResult> Brand(string brandId) | ||
{ | ||
var value = HttpContext.Request.Query["filter[filters][0][value]"].ToString(); | ||
|
||
async Task<IList<SearchModel>> PrepareModel(IEnumerable<Brand> brands) | ||
{ | ||
var model = new List<SearchModel>(); | ||
if (!string.IsNullOrEmpty(brandId)) | ||
{ | ||
var currentBrand = await _brandService.GetBrandById(brandId); | ||
if (currentBrand != null) | ||
{ | ||
model.Add(new SearchModel { | ||
Id = currentBrand.Id, | ||
Name = currentBrand.Name | ||
}); | ||
} | ||
} | ||
|
||
model.AddRange(from item in brands where item.Id != brandId select new SearchModel { Id = item.Id, Name = item.Name }); | ||
return model; | ||
} | ||
var brands = await _brandService.GetAllBrands( | ||
brandName: value, | ||
pageSize: _adminSearchSettings.BrandSizeLimit); | ||
var gridModel = new DataSourceResult | ||
{ | ||
Data = await PrepareModel(brands) | ||
}; | ||
return Json(gridModel); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
src/Web/Grand.Web.Vendor/Models/Catalog/ProductReviewListModel.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Grand.Web.Vendor.Models.Common | ||
{ | ||
public class SearchModel | ||
{ | ||
public string Id { get; set; } | ||
public string Name { get; set; } | ||
} | ||
} |
Oops, something went wrong.