11using Grand . Business . Core . Interfaces . Catalog . Products ;
2- using Grand . Business . Core . Interfaces . Common . Directory ;
32using Grand . Business . Core . Interfaces . Common . Localization ;
43using Grand . Domain . Permissions ;
5- using Grand . Infrastructure ;
64using Grand . Web . AdminShared . Interfaces ;
75using Grand . Web . AdminShared . Models . Catalog ;
86using Grand . Web . Common . DataSource ;
@@ -20,15 +18,11 @@ public class ProductReviewController : BaseAdminController
2018 public ProductReviewController (
2119 IProductReviewViewModelService productReviewViewModelService ,
2220 IProductReviewService productReviewService ,
23- ITranslationService translationService ,
24- IContextAccessor contextAccessor ,
25- IGroupService groupService )
21+ ITranslationService translationService )
2622 {
2723 _productReviewViewModelService = productReviewViewModelService ;
2824 _productReviewService = productReviewService ;
2925 _translationService = translationService ;
30- _contextAccessor = contextAccessor ;
31- _groupService = groupService ;
3226 }
3327
3428 #endregion
@@ -38,8 +32,6 @@ public ProductReviewController(
3832 private readonly IProductReviewViewModelService _productReviewViewModelService ;
3933 private readonly IProductReviewService _productReviewService ;
4034 private readonly ITranslationService _translationService ;
41- private readonly IContextAccessor _contextAccessor ;
42- private readonly IGroupService _groupService ;
4335
4436 #endregion Fields
4537
@@ -53,19 +45,14 @@ public IActionResult Index()
5345
5446 public async Task < IActionResult > List ( )
5547 {
56- var model = await _productReviewViewModelService . PrepareProductReviewListModel ( _contextAccessor . WorkContext . CurrentCustomer
57- . StaffStoreId ) ;
48+ var model = await _productReviewViewModelService . PrepareProductReviewListModel ( ) ;
5849 return View ( model ) ;
5950 }
6051
6152 [ PermissionAuthorizeAction ( PermissionActionName . List ) ]
6253 [ HttpPost ]
6354 public async Task < IActionResult > List ( DataSourceRequest command , ProductReviewListModel model )
6455 {
65- //limit for store manager
66- if ( await _groupService . IsStoreManager ( _contextAccessor . WorkContext . CurrentCustomer ) )
67- model . SearchStoreId = _contextAccessor . WorkContext . CurrentCustomer . StaffStoreId ;
68-
6956 var ( productReviewModels , totalCount ) =
7057 await _productReviewViewModelService . PrepareProductReviewsModel ( model , command . Page , command . PageSize ) ;
7158 var gridModel = new DataSourceResult {
@@ -86,9 +73,6 @@ public async Task<IActionResult> Edit(string id)
8673 //No product review found with the specified id
8774 return RedirectToAction ( "List" ) ;
8875
89- if ( await _groupService . IsStoreManager ( _contextAccessor . WorkContext . CurrentCustomer ) &&
90- productReview . StoreId != _contextAccessor . WorkContext . CurrentCustomer . StaffStoreId ) return RedirectToAction ( "List" ) ;
91-
9276 var model = new ProductReviewModel ( ) ;
9377 await _productReviewViewModelService . PrepareProductReviewModel ( model , productReview , false , false ) ;
9478 return View ( model ) ;
@@ -104,15 +88,12 @@ public async Task<IActionResult> Edit(ProductReviewModel model, bool continueEdi
10488 //No product review found with the specified id
10589 return RedirectToAction ( "List" ) ;
10690
107- if ( await _groupService . IsStoreManager ( _contextAccessor . WorkContext . CurrentCustomer ) &&
108- productReview . StoreId != _contextAccessor . WorkContext . CurrentCustomer . StaffStoreId ) return RedirectToAction ( "List" ) ;
109-
11091 if ( ModelState . IsValid )
11192 {
11293 productReview = await _productReviewViewModelService . UpdateProductReview ( productReview , model ) ;
11394 Success ( _translationService . GetResource ( "Admin.Catalog.ProductReviews.Updated" ) ) ;
11495 return continueEditing
115- ? RedirectToAction ( "Edit" , new { id = productReview . Id , productReview . ProductId } )
96+ ? RedirectToAction ( "Edit" , new { productReview . Id , productReview . ProductId } )
11697 : RedirectToAction ( "List" ) ;
11798 }
11899
@@ -131,9 +112,6 @@ public async Task<IActionResult> Delete(string id)
131112 //No product review found with the specified id
132113 return RedirectToAction ( "List" ) ;
133114
134- if ( await _groupService . IsStoreManager ( _contextAccessor . WorkContext . CurrentCustomer ) &&
135- productReview . StoreId != _contextAccessor . WorkContext . CurrentCustomer . StaffStoreId ) return RedirectToAction ( "List" ) ;
136-
137115 if ( ModelState . IsValid )
138116 {
139117 await _productReviewViewModelService . DeleteProductReview ( productReview ) ;
@@ -150,8 +128,7 @@ public async Task<IActionResult> Delete(string id)
150128 public async Task < IActionResult > ApproveSelected ( ICollection < string > selectedIds )
151129 {
152130 if ( selectedIds != null )
153- await _productReviewViewModelService . ApproveSelected ( selectedIds . ToList ( ) ,
154- _contextAccessor . WorkContext . CurrentCustomer . StaffStoreId ) ;
131+ await _productReviewViewModelService . ApproveSelected ( selectedIds . ToList ( ) ) ;
155132
156133 return Json ( new { Result = true } ) ;
157134 }
@@ -161,8 +138,7 @@ await _productReviewViewModelService.ApproveSelected(selectedIds.ToList(),
161138 public async Task < IActionResult > DisapproveSelected ( ICollection < string > selectedIds )
162139 {
163140 if ( selectedIds != null )
164- await _productReviewViewModelService . DisapproveSelected ( selectedIds . ToList ( ) ,
165- _contextAccessor . WorkContext . CurrentCustomer . StaffStoreId ) ;
141+ await _productReviewViewModelService . DisapproveSelected ( selectedIds . ToList ( ) ) ;
166142
167143 return Json ( new { Result = true } ) ;
168144 }
@@ -175,23 +151,19 @@ public async Task<IActionResult> ProductSearchAutoComplete(string term,
175151 if ( string . IsNullOrWhiteSpace ( term ) || term . Length < searchTermMinimumLength )
176152 return Content ( "" ) ;
177153
178- var storeId = string . Empty ;
179- if ( await _groupService . IsStoreManager ( _contextAccessor . WorkContext . CurrentCustomer ) )
180- storeId = _contextAccessor . WorkContext . CurrentCustomer . StaffStoreId ;
181-
182154 //products
183155 const int productNumber = 15 ;
184156 var products = ( await productService . SearchProducts (
185- storeId : storeId ,
186157 keywords : term ,
187158 pageSize : productNumber ,
188159 showHidden : true ) ) . products ;
189160
190161 var result = ( from p in products
191- select new {
192- label = p . Name ,
193- productid = p . Id
194- } )
162+ select new
163+ {
164+ label = p . Name ,
165+ productid = p . Id
166+ } )
195167 . ToList ( ) ;
196168 return Json ( result ) ;
197169 }
0 commit comments