jjghjgh
This commit is contained in:
parent
cab7d1c2aa
commit
1b60684f85
|
|
@ -6,37 +6,37 @@ using Nop.Web.Framework.Mvc.Filters;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers;
|
namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers;
|
||||||
|
|
||||||
public partial class PreorderAdminController
|
public partial class PreOrderAdminController
|
||||||
{
|
{
|
||||||
[HttpPost, Route("Admin/Preorders/UpdateHeader/{id:int}")]
|
[HttpPost, Route("Admin/PreOrders/UpdateHeader/{id:int}")]
|
||||||
public async Task<IActionResult> UpdateHeader(int id, string deliveryDateTime, string? customerNote)
|
public async Task<IActionResult> UpdateHeader(int id, string deliveryDateTime, string? customerNote)
|
||||||
{
|
{
|
||||||
if (!await _permissionService.AuthorizeAsync(StandardPermission.Security.ACCESS_ADMIN_PANEL)) return Forbid();
|
if (!await _permissionService.AuthorizeAsync(StandardPermission.Security.ACCESS_ADMIN_PANEL)) return Forbid();
|
||||||
var p = await _preorderDbContext.Preorders.GetByIdAsync(id);
|
var p = await _preorderDbContext.PreOrders.GetByIdAsync(id);
|
||||||
if (p == null || p.Status == PreorderStatus.Cancelled) return Json(new { success = false });
|
if (p == null || p.Status == PreOrderStatus.Cancelled) return Json(new { success = false });
|
||||||
if (!DateTime.TryParse(deliveryDateTime, out var d)) return Json(new { success = false, error = "Érvénytelen dátum" });
|
if (!DateTime.TryParse(deliveryDateTime, out var d)) return Json(new { success = false, error = "Érvénytelen dátum" });
|
||||||
p.DateOfReceipt = d; p.CustomerNote = customerNote?.Trim(); p.UpdatedOnUtc = DateTime.UtcNow;
|
p.DateOfReceipt = d; p.CustomerNote = customerNote?.Trim(); p.UpdatedOnUtc = DateTime.UtcNow;
|
||||||
await _preorderDbContext.Preorders.UpdateAsync(p);
|
await _preorderDbContext.PreOrders.UpdateAsync(p);
|
||||||
return Json(new { success = true });
|
return Json(new { success = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, Route("Admin/Preorders/UpdateItem/{id:int}")]
|
[HttpPost, Route("Admin/PreOrders/UpdateItem/{id:int}")]
|
||||||
public async Task<IActionResult> UpdateItem(int id, int quantity, decimal unitPrice)
|
public async Task<IActionResult> UpdateItem(int id, int quantity, decimal unitPrice)
|
||||||
{
|
{
|
||||||
if (!await _permissionService.AuthorizeAsync(StandardPermission.Security.ACCESS_ADMIN_PANEL)) return Forbid();
|
if (!await _permissionService.AuthorizeAsync(StandardPermission.Security.ACCESS_ADMIN_PANEL)) return Forbid();
|
||||||
var item = await _preorderDbContext.PreorderItems.GetByIdAsync(id);
|
var item = await _preorderDbContext.PreOrderItems.GetByIdAsync(id);
|
||||||
if (item == null || item.FulfilledQuantity > 0) return Json(new { success = false, error = "Módosítás nem lehetséges" });
|
if (item == null || item.FulfilledQuantity > 0) return Json(new { success = false, error = "Módosítás nem lehetséges" });
|
||||||
item.RequestedQuantity = Math.Max(1, quantity);
|
item.RequestedQuantity = Math.Max(1, quantity);
|
||||||
item.UnitPriceInclTax = Math.Max(0, unitPrice);
|
item.UnitPriceInclTax = Math.Max(0, unitPrice);
|
||||||
await _preorderDbContext.PreorderItems.UpdateAsync(item);
|
await _preorderDbContext.PreOrderItems.UpdateAsync(item);
|
||||||
return Json(new { success = true });
|
return Json(new { success = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, Route("Admin/Preorders/ReplaceItemProduct/{id:int}")]
|
[HttpPost, Route("Admin/PreOrders/ReplaceItemProduct/{id:int}")]
|
||||||
public async Task<IActionResult> ReplaceItemProduct(int id, int newProductId)
|
public async Task<IActionResult> ReplaceItemProduct(int id, int newProductId)
|
||||||
{
|
{
|
||||||
if (!await _permissionService.AuthorizeAsync(StandardPermission.Security.ACCESS_ADMIN_PANEL)) return Forbid();
|
if (!await _permissionService.AuthorizeAsync(StandardPermission.Security.ACCESS_ADMIN_PANEL)) return Forbid();
|
||||||
var item = await _preorderDbContext.PreorderItems.GetByIdAsync(id);
|
var item = await _preorderDbContext.PreOrderItems.GetByIdAsync(id);
|
||||||
if (item == null || item.FulfilledQuantity > 0) return Json(new { success = false, error = "Csere nem lehetséges" });
|
if (item == null || item.FulfilledQuantity > 0) return Json(new { success = false, error = "Csere nem lehetséges" });
|
||||||
var product = await _dbContext.Products.GetByIdAsync(newProductId);
|
var product = await _dbContext.Products.GetByIdAsync(newProductId);
|
||||||
if (product == null || product.Deleted) return Json(new { success = false, error = "Termék nem található" });
|
if (product == null || product.Deleted) return Json(new { success = false, error = "Termék nem található" });
|
||||||
|
|
@ -44,7 +44,7 @@ public partial class PreorderAdminController
|
||||||
item.ProductId = newProductId;
|
item.ProductId = newProductId;
|
||||||
|
|
||||||
// Recalculate price for the preorder's customer using CustomPriceCalculationService
|
// Recalculate price for the preorder's customer using CustomPriceCalculationService
|
||||||
var preorder = await _preorderDbContext.Preorders.GetByIdAsync(item.PreorderId);
|
var preorder = await _preorderDbContext.PreOrders.GetByIdAsync(item.PreOrderId);
|
||||||
var customer = preorder != null ? await _customerService.GetCustomerByIdAsync(preorder.CustomerId) : null;
|
var customer = preorder != null ? await _customerService.GetCustomerByIdAsync(preorder.CustomerId) : null;
|
||||||
if (customer != null)
|
if (customer != null)
|
||||||
{
|
{
|
||||||
|
|
@ -53,23 +53,23 @@ public partial class PreorderAdminController
|
||||||
item.UnitPriceInclTax = calc.finalPrice;
|
item.UnitPriceInclTax = calc.finalPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
await _preorderDbContext.PreorderItems.UpdateAsync(item);
|
await _preorderDbContext.PreOrderItems.UpdateAsync(item);
|
||||||
return Json(new { success = true, productName = product.Name, newPrice = item.UnitPriceInclTax });
|
return Json(new { success = true, productName = product.Name, newPrice = item.UnitPriceInclTax });
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, Route("Admin/Preorders/ConvertNow/{id:int}")]
|
[HttpPost, Route("Admin/PreOrders/ConvertNow/{id:int}")]
|
||||||
public async Task<IActionResult> ConvertNow(int id)
|
public async Task<IActionResult> ConvertNow(int id)
|
||||||
{
|
{
|
||||||
if (!await _permissionService.AuthorizeAsync(StandardPermission.Security.ACCESS_ADMIN_PANEL)) return Forbid();
|
if (!await _permissionService.AuthorizeAsync(StandardPermission.Security.ACCESS_ADMIN_PANEL)) return Forbid();
|
||||||
var preorder = await _preorderDbContext.Preorders.GetByIdAsync(id);
|
var preorder = await _preorderDbContext.PreOrders.GetByIdAsync(id);
|
||||||
if (preorder == null || preorder.Status == PreorderStatus.Cancelled)
|
if (preorder == null || preorder.Status == PreOrderStatus.Cancelled)
|
||||||
return Json(new { success = false, error = "Konvertálás nem lehetséges" });
|
return Json(new { success = false, error = "Konvertálás nem lehetséges" });
|
||||||
var pending = await _preorderDbContext.PreorderItems.GetAll()
|
var pending = await _preorderDbContext.PreOrderItems.GetAll()
|
||||||
.Where(i => i.PreorderId == id && i.FulfilledQuantity < i.RequestedQuantity).ToListAsync();
|
.Where(i => i.PreOrderId == id && i.FulfilledQuantity < i.RequestedQuantity).ToListAsync();
|
||||||
if (!pending.Any()) return Json(new { success = false, error = "Nincs teljesítetlen tétel" });
|
if (!pending.Any()) return Json(new { success = false, error = "Nincs teljesítetlen tétel" });
|
||||||
await _preorderConversionService.ConvertPreordersForProductsAsync(
|
await _preorderConversionService.ConvertPreOrdersForProductsAsync(
|
||||||
pending.Select(i => i.ProductId).Distinct().ToList(), 0);
|
pending.Select(i => i.ProductId).Distinct().ToList(), 0);
|
||||||
var refreshed = await _preorderDbContext.Preorders.GetByIdAsync(id);
|
var refreshed = await _preorderDbContext.PreOrders.GetByIdAsync(id);
|
||||||
return Json(new { success = true, orderId = refreshed?.OrderId });
|
return Json(new { success = true, orderId = refreshed?.OrderId });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -151,12 +151,15 @@
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.AspNetCore.Http.Connections.Client">
|
<Reference Include="Microsoft.AspNetCore.Http.Connections.Client">
|
||||||
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\$(Configuration)\net9.0\Microsoft.AspNetCore.Http.Connections.Client.dll</HintPath>
|
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\$(Configuration)\net9.0\Microsoft.AspNetCore.Http.Connections.Client.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.AspNetCore.SignalR.Client">
|
<Reference Include="Microsoft.AspNetCore.SignalR.Client">
|
||||||
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\$(Configuration)\net9.0\Microsoft.AspNetCore.SignalR.Client.dll</HintPath>
|
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\$(Configuration)\net9.0\Microsoft.AspNetCore.SignalR.Client.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.AspNetCore.SignalR.Client.Core">
|
<Reference Include="Microsoft.AspNetCore.SignalR.Client.Core">
|
||||||
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\$(Configuration)\net9.0\Microsoft.AspNetCore.SignalR.Client.Core.dll</HintPath>
|
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\$(Configuration)\net9.0\Microsoft.AspNetCore.SignalR.Client.Core.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson">
|
<Reference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson">
|
||||||
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\$(Configuration)\net9.0\Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson.dll</HintPath>
|
<HintPath>..\..\..\..\FruitBankHybridApp\FruitBank.Common.Server\bin\$(Configuration)\net9.0\Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson.dll</HintPath>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue