Skip to content

Commit 7cf1f9a

Browse files
Add Merchandise
1 parent 11a05b7 commit 7cf1f9a

File tree

9 files changed

+1011
-43
lines changed

9 files changed

+1011
-43
lines changed

src/Web/Grand.Web.Admin/Controllers/MerchandiseReturnController.cs

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
using Grand.Business.Core.Interfaces.Checkout.Orders;
22
using Grand.Business.Core.Interfaces.Common.Addresses;
3-
using Grand.Business.Core.Interfaces.Common.Directory;
43
using Grand.Business.Core.Interfaces.Common.Localization;
5-
using Grand.Domain.Permissions;
64
using Grand.Domain.Common;
75
using Grand.Domain.Orders;
8-
using Grand.Infrastructure;
9-
using Grand.Web.Admin.Extensions;
6+
using Grand.Domain.Permissions;
7+
using Grand.Web.AdminShared.Extensions;
108
using Grand.Web.AdminShared.Interfaces;
119
using Grand.Web.AdminShared.Models.Orders;
1210
using Grand.Web.Common.DataSource;
1311
using Grand.Web.Common.Filters;
1412
using Grand.Web.Common.Security.Authorization;
1513
using Microsoft.AspNetCore.Mvc;
16-
using Grand.Web.AdminShared.Extensions;
1714

1815
namespace Grand.Web.Admin.Controllers;
1916

@@ -26,16 +23,12 @@ public MerchandiseReturnController(
2623
IMerchandiseReturnViewModelService merchandiseReturnViewModelService,
2724
ITranslationService translationService,
2825
IMerchandiseReturnService merchandiseReturnService,
29-
IOrderService orderService,
30-
IContextAccessor contextAccessor,
31-
IGroupService groupService)
26+
IOrderService orderService)
3227
{
3328
_merchandiseReturnViewModelService = merchandiseReturnViewModelService;
3429
_translationService = translationService;
3530
_merchandiseReturnService = merchandiseReturnService;
3631
_orderService = orderService;
37-
_contextAccessor = contextAccessor;
38-
_groupService = groupService;
3932
}
4033

4134
#endregion
@@ -46,8 +39,6 @@ public MerchandiseReturnController(
4639
private readonly ITranslationService _translationService;
4740
private readonly IMerchandiseReturnService _merchandiseReturnService;
4841
private readonly IOrderService _orderService;
49-
private readonly IContextAccessor _contextAccessor;
50-
private readonly IGroupService _groupService;
5142

5243
#endregion Fields
5344

@@ -69,11 +60,7 @@ public IActionResult List()
6960
[HttpPost]
7061
public async Task<IActionResult> List(DataSourceRequest command, MerchandiseReturnListModel model)
7162
{
72-
if (await _groupService.IsStoreManager(_contextAccessor.WorkContext.CurrentCustomer))
73-
model.StoreId = _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId;
74-
var merchandiseReturnModels =
75-
await _merchandiseReturnViewModelService.PrepareMerchandiseReturnModel(model, command.Page,
76-
command.PageSize);
63+
var merchandiseReturnModels = await _merchandiseReturnViewModelService.PrepareMerchandiseReturnModel(model, command.Page, command.PageSize);
7764
var gridModel = new DataSourceResult {
7865
Data = merchandiseReturnModels.merchandiseReturnModels,
7966
Total = merchandiseReturnModels.totalCount
@@ -97,10 +84,6 @@ public async Task<IActionResult> GoToId(MerchandiseReturnListModel model)
9784
//not found
9885
return RedirectToAction("List", "MerchandiseReturn");
9986

100-
if (await _groupService.IsStoreManager(_contextAccessor.WorkContext.CurrentCustomer) &&
101-
merchandiseReturn.StoreId != _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId)
102-
return RedirectToAction("List", "MerchandiseReturn");
103-
10487
return RedirectToAction("Edit", "MerchandiseReturn", new { id = merchandiseReturn.Id });
10588
}
10689

@@ -112,9 +95,6 @@ public async Task<IActionResult> ProductsForMerchandiseReturn(string merchandise
11295
if (merchandiseReturn == null)
11396
return ErrorForKendoGridJson("Merchandise return not found");
11497

115-
if (await _groupService.IsStoreManager(_contextAccessor.WorkContext.CurrentCustomer) &&
116-
merchandiseReturn.StoreId != _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId)
117-
return ErrorForKendoGridJson("Merchandise return is not your");
11898
var items = await _merchandiseReturnViewModelService.PrepareMerchandiseReturnItemModel(merchandiseReturnId);
11999
var gridModel = new DataSourceResult {
120100
Data = items,
@@ -133,9 +113,6 @@ public async Task<IActionResult> Edit(string id)
133113
//No merchandise return found with the specified id
134114
return RedirectToAction("List");
135115

136-
if (await _groupService.IsStoreManager(_contextAccessor.WorkContext.CurrentCustomer) &&
137-
merchandiseReturn.StoreId != _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId)
138-
return RedirectToAction("List", "MerchandiseReturn");
139116
var model = new MerchandiseReturnModel();
140117
await _merchandiseReturnViewModelService.PrepareMerchandiseReturnModel(model, merchandiseReturn, false);
141118
return View(model);
@@ -155,10 +132,6 @@ [FromServices] OrderSettings orderSettings
155132
//No merchandise return found with the specified id
156133
return RedirectToAction("List");
157134

158-
if (await _groupService.IsStoreManager(_contextAccessor.WorkContext.CurrentCustomer) &&
159-
merchandiseReturn.StoreId != _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId)
160-
return RedirectToAction("List", "MerchandiseReturn");
161-
162135
if (ModelState.IsValid)
163136
{
164137
var customAddressAttributes = new List<CustomAttribute>();
@@ -191,9 +164,6 @@ public async Task<IActionResult> Delete(string id)
191164
//No merchandise return found with the specified id
192165
return RedirectToAction("List");
193166

194-
if (await _groupService.IsStoreManager(_contextAccessor.WorkContext.CurrentCustomer) &&
195-
merchandiseReturn.StoreId != _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId)
196-
return RedirectToAction("List", "MerchandiseReturn");
197167
if (ModelState.IsValid)
198168
{
199169
await _merchandiseReturnViewModelService.DeleteMerchandiseReturn(merchandiseReturn);
@@ -217,11 +187,8 @@ public async Task<IActionResult> MerchandiseReturnNotesSelect(string merchandise
217187
if (merchandiseReturn == null)
218188
throw new ArgumentException("No merchandise return found with the specified id");
219189

220-
if (await _groupService.IsStoreManager(_contextAccessor.WorkContext.CurrentCustomer) &&
221-
merchandiseReturn.StoreId != _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId) return Content("");
222190
//merchandise return notes
223-
var merchandiseReturnNoteModels =
224-
await _merchandiseReturnViewModelService.PrepareMerchandiseReturnNotes(merchandiseReturn);
191+
var merchandiseReturnNoteModels = await _merchandiseReturnViewModelService.PrepareMerchandiseReturnNotes(merchandiseReturn);
225192
var gridModel = new DataSourceResult {
226193
Data = merchandiseReturnNoteModels,
227194
Total = merchandiseReturnNoteModels.Count
@@ -241,8 +208,6 @@ public async Task<IActionResult> MerchandiseReturnNoteAdd(string merchandiseRetu
241208
if (order == null)
242209
return Json(new { Result = false });
243210

244-
if (await _groupService.IsStoreManager(_contextAccessor.WorkContext.CurrentCustomer) &&
245-
merchandiseReturn.StoreId != _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId) return Json(new { Result = false });
246211
await _merchandiseReturnViewModelService.InsertMerchandiseReturnNote(merchandiseReturn, order, downloadId,
247212
displayToCustomer, message);
248213

@@ -257,9 +222,6 @@ public async Task<IActionResult> MerchandiseReturnNoteDelete(string id, string m
257222
if (merchandiseReturn == null)
258223
throw new ArgumentException("No merchandise return found with the specified id");
259224

260-
if (await _groupService.IsStoreManager(_contextAccessor.WorkContext.CurrentCustomer) &&
261-
merchandiseReturn.StoreId != _contextAccessor.WorkContext.CurrentCustomer.StaffStoreId) return Json(new { Result = false });
262-
263225
await _merchandiseReturnViewModelService.DeleteMerchandiseReturnNote(merchandiseReturn, id);
264226

265227
return new JsonResult("");
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@model MerchandiseReturnModel
2+
@{
3+
//page title
4+
ViewBag.Title = Loc["Admin.Orders.MerchandiseReturns.EditMerchandiseReturnDetails"];
5+
}
6+
<form asp-area="@Constants.AreaStore" asp-controller="MerchandiseReturn" asp-action="Edit" method="post">
7+
8+
<div class="row">
9+
<div class="col-md-12">
10+
<div class="x_panel light form-fit">
11+
<div class="x_title">
12+
<div class="caption">
13+
<i class="fa fa-truck"></i>
14+
@Loc["Admin.Orders.MerchandiseReturns.EditMerchandiseReturnDetails"]
15+
<small>
16+
<i class="fa fa-arrow-circle-left"></i> @Html.ActionLink(Loc["Admin.Orders.MerchandiseReturns.BackToList"], "List")
17+
</small>
18+
</div>
19+
<div class="actions">
20+
<div class="btn-group btn-group-devided">
21+
<button class="btn btn-success" type="submit" name="save">
22+
<i class="fa fa-check"></i> @Loc["Admin.Common.Save"]
23+
</button>
24+
<button class="btn btn-success" type="submit" name="save-continue">
25+
<i class="fa fa-check-circle"></i> @Loc["Admin.Common.SaveContinue"]
26+
</button>
27+
<span id="merchandisereturn-delete" class="btn red">
28+
<i class="fa fa-trash-o"></i> @Loc["Admin.Common.Delete"]
29+
</span>
30+
<vc:admin-widget widget-zone="merchandisereturn_details_buttons" additional-data="Model"/>
31+
</div>
32+
</div>
33+
</div>
34+
<div class="x_content form">
35+
<partial name="Partials/CreateOrUpdate" model="Model"/>
36+
</div>
37+
</div>
38+
</div>
39+
</div>
40+
</form>
41+
<admin-delete-confirmation button-id="merchandisereturn-delete"/>

0 commit comments

Comments
 (0)