merge
This commit is contained in:
commit
b822711be7
|
|
@ -0,0 +1,101 @@
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
|
using Nop.Services.Catalog;
|
||||||
|
using Nop.Services.Cms;
|
||||||
|
using Nop.Services.Common;
|
||||||
|
using Nop.Services.Logging;
|
||||||
|
using Nop.Web.Areas.Admin.Components;
|
||||||
|
using Nop.Web.Areas.Admin.Models.Catalog;
|
||||||
|
using Nop.Web.Areas.Admin.Models.Orders;
|
||||||
|
using Nop.Web.Framework.Components;
|
||||||
|
using Nop.Web.Framework.Factories;
|
||||||
|
using Nop.Web.Framework.Infrastructure;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Components
|
||||||
|
{
|
||||||
|
[ViewComponent(Name = "AuctionAdmin")]
|
||||||
|
public class AuctionAdminViewComponent : AdminWidgetViewComponent
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
protected readonly ILogger _logger;
|
||||||
|
protected readonly IProductAttributeService _productAttributeService;
|
||||||
|
protected readonly IWidgetPluginManager _widgetPluginManager;
|
||||||
|
protected readonly AuctionSettings _auctionSettings;
|
||||||
|
protected readonly IAuctionService _auctionService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Ctor
|
||||||
|
|
||||||
|
public AuctionAdminViewComponent(
|
||||||
|
IWidgetModelFactory widgetModelFactory,
|
||||||
|
ILogger logger,
|
||||||
|
IProductAttributeService productAttributeService,
|
||||||
|
IWidgetPluginManager widgetPluginManager,
|
||||||
|
AuctionSettings auctionSettings,
|
||||||
|
IAuctionService auctionService) : base(widgetModelFactory)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_productAttributeService = productAttributeService;
|
||||||
|
_widgetPluginManager = widgetPluginManager;
|
||||||
|
_auctionSettings = auctionSettings;
|
||||||
|
_auctionService = auctionService;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoke the widget view component
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="widgetZone">Widget zone</param>
|
||||||
|
/// <param name="additionalData">Additional parameters</param>
|
||||||
|
/// <returns>
|
||||||
|
/// A task that represents the asynchronous operation
|
||||||
|
/// The task result contains the view component result
|
||||||
|
/// </returns>
|
||||||
|
public override async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
||||||
|
{
|
||||||
|
|
||||||
|
//await base.InvokeAsync(widgetZone, additionalData);
|
||||||
|
await _logger.InformationAsync($"Admin auction widget called from {widgetZone}!");
|
||||||
|
if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName))
|
||||||
|
return Content(string.Empty);
|
||||||
|
|
||||||
|
//if (!_auctionSettings.Enabled)
|
||||||
|
// return Content(string.Empty);
|
||||||
|
|
||||||
|
//if (additionalData is not ProductDetailsModel model)
|
||||||
|
// return Content(string.Empty);
|
||||||
|
|
||||||
|
var productId = 0;
|
||||||
|
if (!widgetZone.Equals(AdminWidgetZones.ProductDetailsButtons))
|
||||||
|
{
|
||||||
|
await _logger.InformationAsync($"Admin auction widget not in the right widgetzone {widgetZone}!");
|
||||||
|
return Content(string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
var product = (additionalData as ProductModel);
|
||||||
|
productId = product.Id;
|
||||||
|
|
||||||
|
var auctions = await _auctionService.GetAllAuctionsAsync() ?? new List<Auction>();
|
||||||
|
|
||||||
|
// Assign the auctions to the ViewBag
|
||||||
|
ViewBag.Auctions = auctions;
|
||||||
|
ProductAssignToAuctionViewModel viewModel = new ProductAssignToAuctionViewModel();
|
||||||
|
viewModel.StartingPrice = product.BasepriceAmount;
|
||||||
|
await _logger.InformationAsync($"Admin auction widget called from {widgetZone}! II. ");
|
||||||
|
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/AdminProductAuctionSettingsBox.cshtml", productId.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -10,6 +10,7 @@ using Nop.Services.Localization;
|
||||||
using Nop.Services.Logging;
|
using Nop.Services.Logging;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
|
using Nop.Web.Framework.Models.DataTables;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers;
|
namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers;
|
||||||
|
|
||||||
|
|
@ -84,12 +85,21 @@ public class AuctionPluginAdminController : BasePluginController
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
public IActionResult GetAuctionViewModel()
|
public IActionResult GetAuctionViewModel()
|
||||||
{
|
{
|
||||||
var model = new AuctionViewModel();
|
var model = new AuctionViewModel();
|
||||||
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/Auction.cshtml", model);
|
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/Auction.cshtml", model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<IActionResult> AuctionList()
|
||||||
|
{
|
||||||
|
await _logger.InformationAsync("AnnouncementList called!");
|
||||||
|
var model = new AuctionViewModel();
|
||||||
|
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/AuctionList.cshtml", model);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> GetAuctionViewModel(AuctionViewModel viewModel)
|
public async Task<IActionResult> GetAuctionViewModel(AuctionViewModel viewModel)
|
||||||
{
|
{
|
||||||
|
|
@ -110,6 +120,29 @@ public class AuctionPluginAdminController : BasePluginController
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> GetAuctionList()
|
||||||
|
{
|
||||||
|
//await _logger.InformationAsync("GetAnnouncementList called!");
|
||||||
|
//var total = (await _announcementService.GetAnnouncementsAsync()).Count();
|
||||||
|
//var result = await _announcementService.GetAnnouncementsAsync(request.Page, request.PageSize);
|
||||||
|
|
||||||
|
//return Json(new
|
||||||
|
//{
|
||||||
|
// Data = result,
|
||||||
|
// Total = total
|
||||||
|
//});
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Ok(new DataTablesModel { Data = await _auctionService.GetAllAuctionsAsync() });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return BadRequest(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> TestPage()
|
public async Task<IActionResult> TestPage()
|
||||||
{
|
{
|
||||||
var model = new TestPageViewModel();
|
var model = new TestPageViewModel();
|
||||||
|
|
@ -122,4 +155,18 @@ public class AuctionPluginAdminController : BasePluginController
|
||||||
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/TestPage.cshtml", model);
|
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/TestPage.cshtml", model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> AssignProductToAuction(int productId, int auctionId)
|
||||||
|
{
|
||||||
|
if (productId <= 0 || auctionId <= 0)
|
||||||
|
return BadRequest();
|
||||||
|
|
||||||
|
var result = await _auctionService.AssignProductToAuctionAsync(productId, auctionId);
|
||||||
|
if (result)
|
||||||
|
return Ok();
|
||||||
|
|
||||||
|
return StatusCode(500, "Error assigning product to auction.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
using Nop.Web.Framework.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models
|
||||||
|
{
|
||||||
|
public record ProductAssignToAuctionViewModel : BaseNopModel
|
||||||
|
{
|
||||||
|
public int ProductId { get; set; }
|
||||||
|
public int AuctionId { get; set; }
|
||||||
|
public decimal StartingPrice { get; set; }
|
||||||
|
public decimal BidPrice { get; set; }
|
||||||
|
public decimal BidAmount { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
@model ProductAssignToAuctionViewModel
|
||||||
|
<div class="auction-settings-box">
|
||||||
|
<h3>@T("Plugins.Misc.AuctionPlugin.AssignToAuction")</h3>
|
||||||
|
|
||||||
|
<form id="assignAuctionForm" method="post" action="@Url.Action("AssignProductToAuction", "AuctionPluginAdmin", new { area = "Admin" })">
|
||||||
|
<input type="hidden" name="productId" value="@Model.ProductId" />
|
||||||
|
<input type="hidden" name="startingPrice" value="@Model.StartingPrice" />
|
||||||
|
@* <input type="hidden" name="bidPrice" value="@Model.StartingPrice" /> *@
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="auctionSelect">@T("Plugins.Misc.AuctionPlugin.SelectAuction")</label>
|
||||||
|
<select id="auctionSelect" name="auctionId" class="form-control">
|
||||||
|
<option value="">@T("Plugins.Misc.AuctionPlugin.SelectAuctionPlaceholder")</option>
|
||||||
|
@foreach (var auction in ViewBag.Auctions as List<Nop.Plugin.Misc.AuctionPlugin.Domains.Entities.Auction>)
|
||||||
|
{
|
||||||
|
<option value="@auction.Id">@auction.AuctionName</option>
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary">
|
||||||
|
@T("Plugins.Misc.AuctionPlugin.AssignToAuctionButton")
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
$('#assignAuctionForm').on('submit', function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var form = $(this);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: form.attr('action'),
|
||||||
|
type: 'POST',
|
||||||
|
data: form.serialize(),
|
||||||
|
success: function (response) {
|
||||||
|
toastr.success("@T("Plugins.Misc.AuctionPlugin.ProductAssignedSuccess")");
|
||||||
|
},
|
||||||
|
error: function (error) {
|
||||||
|
toastr.error("@T("Plugins.Misc.AuctionPlugin.ProductAssignedError")");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
@using Nop.Core.Infrastructure
|
||||||
|
@using Nop.Web.Framework
|
||||||
|
|
||||||
|
|
||||||
|
@{
|
||||||
|
var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
|
||||||
|
var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;
|
||||||
|
|
||||||
|
Layout = "_AdminLayout";
|
||||||
|
//page title
|
||||||
|
ViewBag.Title = T("Admin.Plugins.HomePageProduct").Text;
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="content-header clearfix">
|
||||||
|
<div class="pull-right">
|
||||||
|
<a href="../GetAnnouncementViewModel" class="btn bg-blue">
|
||||||
|
<i class="fa fa-floppy-o"></i>
|
||||||
|
Add
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<div class="form-horizontal">
|
||||||
|
<div class="panel-group">
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-body">
|
||||||
|
|
||||||
|
@await Html.PartialAsync("Table", new DataTablesModel
|
||||||
|
{
|
||||||
|
Name = "announcement-grid",
|
||||||
|
UrlRead = new DataUrl("GetAuctionList", "AuctionPluginAdmin"),
|
||||||
|
Paging = false,
|
||||||
|
ColumnCollection = new List<ColumnProperty>
|
||||||
|
{
|
||||||
|
new ColumnProperty(nameof(Auction.AuctionName))
|
||||||
|
{
|
||||||
|
Title = "Name",
|
||||||
|
Width = "300"
|
||||||
|
},
|
||||||
|
new ColumnProperty(nameof(Auction.StartDateUtc))
|
||||||
|
{
|
||||||
|
Title = "Starts",
|
||||||
|
Width = "300"
|
||||||
|
},
|
||||||
|
new ColumnProperty(nameof(Auction.Closed))
|
||||||
|
{
|
||||||
|
Title = "Closed",
|
||||||
|
Width = "300"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
@ -28,6 +28,7 @@ public static class AuctionDefaults
|
||||||
public static string AnnouncementRouteName => "Plugin.Misc.AuctionPlugin.Announcement";
|
public static string AnnouncementRouteName => "Plugin.Misc.AuctionPlugin.Announcement";
|
||||||
public static string AnnouncementListRouteName => "Plugin.Misc.AuctionPlugin.AnnouncementList";
|
public static string AnnouncementListRouteName => "Plugin.Misc.AuctionPlugin.AnnouncementList";
|
||||||
public static string AuctionRouteName => "Plugin.Misc.AuctionPlugin.Auction";
|
public static string AuctionRouteName => "Plugin.Misc.AuctionPlugin.Auction";
|
||||||
|
public static string AuctionListRouteName => "Plugin.Misc.AuctionPlugin.AuctionList";
|
||||||
public static string TestPageRouteName => "Plugin.Misc.AuctionPlugin.TestPage";
|
public static string TestPageRouteName => "Plugin.Misc.AuctionPlugin.TestPage";
|
||||||
public static string BidNotificationRouteName => "Plugin.Misc.AuctionPlugin.BidNotification";
|
public static string BidNotificationRouteName => "Plugin.Misc.AuctionPlugin.BidNotification";
|
||||||
public static string RefreshAuctionWidgetRouteName => "Plugin.Misc.AuctionPlugin.RefreshAuctionWidget";
|
public static string RefreshAuctionWidgetRouteName => "Plugin.Misc.AuctionPlugin.RefreshAuctionWidget";
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ using Nop.Core;
|
||||||
using Nop.Core.Domain.Catalog;
|
using Nop.Core.Domain.Catalog;
|
||||||
using Nop.Data;
|
using Nop.Data;
|
||||||
using Nop.Plugin.AuctionPlugin.Components;
|
using Nop.Plugin.AuctionPlugin.Components;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Components;
|
||||||
|
|
||||||
//using Nop.Plugin.Misc.AuctionPlugin.Components;
|
//using Nop.Plugin.Misc.AuctionPlugin.Components;
|
||||||
using Nop.Plugin.Widgets.AuctionPlugin.Components;
|
using Nop.Plugin.Widgets.AuctionPlugin.Components;
|
||||||
using Nop.Services.Catalog;
|
using Nop.Services.Catalog;
|
||||||
|
|
@ -100,12 +102,12 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(widgetZone);
|
ArgumentNullException.ThrowIfNull(widgetZone);
|
||||||
|
|
||||||
if (widgetZone.Equals(PublicWidgetZones.ProductDetailsInsideOverviewButtonsBefore))
|
if (widgetZone.Equals(PublicWidgetZones.ProductDetailsAfterPictures))
|
||||||
{
|
{
|
||||||
return typeof(AuctionPublicViewComponent);
|
return typeof(AuctionPublicViewComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widgetZone.Equals(AdminWidgetZones.ProductDetailsBlock))
|
if (widgetZone.Equals(AdminWidgetZones.ProductDetailsButtons))
|
||||||
{
|
{
|
||||||
return typeof(AuctionAdminViewComponent);
|
return typeof(AuctionAdminViewComponent);
|
||||||
}
|
}
|
||||||
|
|
@ -115,6 +117,11 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
||||||
return typeof(LiveAnnouncementViewComponent);
|
return typeof(LiveAnnouncementViewComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (widgetZone.Equals(PublicWidgetZones.ProductBoxAddinfoBefore))
|
||||||
|
{
|
||||||
|
return typeof(AuctionViewComponent);
|
||||||
|
}
|
||||||
|
|
||||||
return typeof(AuctionViewComponent);
|
return typeof(AuctionViewComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,9 +129,10 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
||||||
{
|
{
|
||||||
return Task.FromResult<IList<string>>(new List<string>
|
return Task.FromResult<IList<string>>(new List<string>
|
||||||
{
|
{
|
||||||
PublicWidgetZones.ProductDetailsInsideOverviewButtonsBefore,
|
PublicWidgetZones.ProductDetailsAfterPictures,
|
||||||
PublicWidgetZones.ProductDetailsBottom,
|
PublicWidgetZones.ProductDetailsBottom,
|
||||||
PublicWidgetZones.HeaderAfter
|
PublicWidgetZones.HeaderAfter,
|
||||||
|
AdminWidgetZones.ProductDetailsButtons
|
||||||
|
|
||||||
//AdminWidgetZones.OrderBillingAddressDetailsBottom,
|
//AdminWidgetZones.OrderBillingAddressDetailsBottom,
|
||||||
//AdminWidgetZones.OrderShippingAddressDetailsBottom
|
//AdminWidgetZones.OrderShippingAddressDetailsBottom
|
||||||
|
|
@ -166,6 +174,14 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
||||||
Url = "~/Admin/AuctionPluginAdmin/GetAuctionViewModel"
|
Url = "~/Admin/AuctionPluginAdmin/GetAuctionViewModel"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
liveAnnouncementPluginNode.ChildNodes.Add(new SiteMapNode()
|
||||||
|
{
|
||||||
|
Title = await _localizationService.GetResourceAsync("Misc.AuctionList"),
|
||||||
|
Visible = true,
|
||||||
|
IconClass = "fa-dot-circle-o",
|
||||||
|
Url = "~/Admin/AuctionPluginAdmin/AuctionList"
|
||||||
|
});
|
||||||
|
|
||||||
liveAnnouncementPluginNode.ChildNodes.Add(new SiteMapNode()
|
liveAnnouncementPluginNode.ChildNodes.Add(new SiteMapNode()
|
||||||
{
|
{
|
||||||
Title = await _localizationService.GetResourceAsync("Misc.Announcement"),
|
Title = await _localizationService.GetResourceAsync("Misc.Announcement"),
|
||||||
|
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Nop.Plugin.Misc.AuctionPlugin;
|
|
||||||
using Nop.Services.Catalog;
|
|
||||||
using Nop.Services.Cms;
|
|
||||||
using Nop.Services.Common;
|
|
||||||
using Nop.Web.Areas.Admin.Models.Orders;
|
|
||||||
using Nop.Web.Framework.Components;
|
|
||||||
using Nop.Web.Framework.Infrastructure;
|
|
||||||
using Nop.Web.Models.Catalog;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.AuctionPlugin.Components
|
|
||||||
{
|
|
||||||
[ViewComponent(Name = "AuctionAdmin")]
|
|
||||||
public class AuctionAdminViewComponent : NopViewComponent
|
|
||||||
{
|
|
||||||
#region Fields
|
|
||||||
|
|
||||||
protected readonly IAddressService _addressService;
|
|
||||||
protected readonly IProductAttributeService _productAttributeService;
|
|
||||||
protected readonly IWidgetPluginManager _widgetPluginManager;
|
|
||||||
protected readonly AuctionSettings _auctionSettings;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Ctor
|
|
||||||
|
|
||||||
public AuctionAdminViewComponent(IAddressService addressService,
|
|
||||||
IProductAttributeService productAttributeService,
|
|
||||||
IWidgetPluginManager widgetPluginManager,
|
|
||||||
AuctionSettings auctionSettings)
|
|
||||||
{
|
|
||||||
_addressService = addressService;
|
|
||||||
_productAttributeService = productAttributeService;
|
|
||||||
_widgetPluginManager = widgetPluginManager;
|
|
||||||
_auctionSettings = auctionSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Methods
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invoke the widget view component
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="widgetZone">Widget zone</param>
|
|
||||||
/// <param name="additionalData">Additional parameters</param>
|
|
||||||
/// <returns>
|
|
||||||
/// A task that represents the asynchronous operation
|
|
||||||
/// The task result contains the view component result
|
|
||||||
/// </returns>
|
|
||||||
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName))
|
|
||||||
return Content(string.Empty);
|
|
||||||
|
|
||||||
if (!_auctionSettings.Enabled)
|
|
||||||
return Content(string.Empty);
|
|
||||||
|
|
||||||
//if (additionalData is not ProductDetailsModel model)
|
|
||||||
// return Content(string.Empty);
|
|
||||||
|
|
||||||
var productId = 0;
|
|
||||||
if (widgetZone.Equals(AdminWidgetZones.ProductDetailsBlock))
|
|
||||||
productId = (additionalData as ProductDetailsModel).Id;
|
|
||||||
|
|
||||||
return View("~/Plugins/Misc.AuctionPlugin/Views/AdminProductAuctionSettingsBox.cshtml", productId.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -85,7 +85,7 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
// return Content(string.Empty);
|
// return Content(string.Empty);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (!widgetZone.Equals(PublicWidgetZones.ProductDetailsInsideOverviewButtonsBefore))
|
if (!widgetZone.Equals(PublicWidgetZones.ProductDetailsAfterPictures))
|
||||||
{
|
{
|
||||||
await _logger.InformationAsync($"WidgetViewComponent is NOT in ProductDetailsTop now {widgetZone}");
|
await _logger.InformationAsync($"WidgetViewComponent is NOT in ProductDetailsTop now {widgetZone}");
|
||||||
return Content(string.Empty);
|
return Content(string.Empty);
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,10 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
|
||||||
pattern: "Admin/AuctionPlugin/GetAuctionViewModel",
|
pattern: "Admin/AuctionPlugin/GetAuctionViewModel",
|
||||||
defaults: new { controller = "AuctionPluginAdmin", action = "GetAuctionViewModel" });
|
defaults: new { controller = "AuctionPluginAdmin", action = "GetAuctionViewModel" });
|
||||||
|
|
||||||
|
endpointRouteBuilder.MapControllerRoute(name: AuctionDefaults.AuctionListRouteName,
|
||||||
|
pattern: "Admin/AuctionPlugin/AuctionList",
|
||||||
|
defaults: new { controller = "AuctionPluginAdmin", action = "AuctionList" });
|
||||||
|
|
||||||
endpointRouteBuilder.MapControllerRoute(name: AuctionDefaults.TestPageRouteName,
|
endpointRouteBuilder.MapControllerRoute(name: AuctionDefaults.TestPageRouteName,
|
||||||
pattern: "Admin/Auction/TestPage",
|
pattern: "Admin/Auction/TestPage",
|
||||||
defaults: new { controller = "AuctionPluginAdmin", action = "TestPage" });
|
defaults: new { controller = "AuctionPluginAdmin", action = "TestPage" });
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Areas\Admin\Views\Auction.cshtml" />
|
<None Remove="Areas\Admin\Views\Auction.cshtml" />
|
||||||
|
<None Remove="Areas\Admin\Views\AuctionList.cshtml" />
|
||||||
<None Remove="Areas\Admin\Views\BidNotification.cshtml" />
|
<None Remove="Areas\Admin\Views\BidNotification.cshtml" />
|
||||||
<None Remove="Areas\Admin\Views\TestPage.cshtml" />
|
<None Remove="Areas\Admin\Views\TestPage.cshtml" />
|
||||||
<None Remove="logo.jpg" />
|
<None Remove="logo.jpg" />
|
||||||
|
|
@ -30,6 +31,9 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="Areas\Admin\Views\AuctionList.cshtml">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Areas\Admin\Views\BidNotification.cshtml">
|
<Content Include="Areas\Admin\Views\BidNotification.cshtml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
@ -45,7 +49,7 @@
|
||||||
<Content Include="plugin.json">
|
<Content Include="plugin.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Views\AdminProductAuctionSettingsBox.cshtml">
|
<Content Include="Areas\Admin\Views\AdminProductAuctionSettingsBox.cshtml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<Content Include="Areas\Admin\Views\AnnouncementList.cshtml">
|
<Content Include="Areas\Admin\Views\AnnouncementList.cshtml">
|
||||||
|
|
@ -90,7 +94,6 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Areas\Admin\Components\" />
|
|
||||||
<Folder Include="Areas\Admin\Extensions\" />
|
<Folder Include="Areas\Admin\Extensions\" />
|
||||||
<Folder Include="Areas\Admin\Factories\" />
|
<Folder Include="Areas\Admin\Factories\" />
|
||||||
<Folder Include="Areas\Admin\Validators\" />
|
<Folder Include="Areas\Admin\Validators\" />
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ public class AuctionService : IAuctionService
|
||||||
protected readonly AuctionDbContext _ctx;
|
protected readonly AuctionDbContext _ctx;
|
||||||
//protected readonly IRepository<AuctionBid> _customerBidRepository;
|
//protected readonly IRepository<AuctionBid> _customerBidRepository;
|
||||||
//protected readonly IRepository<Auction> _auctionRepository;
|
//protected readonly IRepository<Auction> _auctionRepository;
|
||||||
|
protected readonly IRepository<ProductToAuctionMapping> _productToAuctionRepository;
|
||||||
protected readonly IShortTermCacheManager _shortTermCacheManager;
|
protected readonly IShortTermCacheManager _shortTermCacheManager;
|
||||||
protected readonly IStaticCacheManager _staticCacheManager;
|
protected readonly IStaticCacheManager _staticCacheManager;
|
||||||
protected readonly IWorkContext _workContext;
|
protected readonly IWorkContext _workContext;
|
||||||
|
|
@ -45,12 +46,12 @@ public class AuctionService : IAuctionService
|
||||||
/// <param name="ctx"></param>
|
/// <param name="ctx"></param>
|
||||||
/// <param name="shortTermCacheManager">Short term cache manager</param>
|
/// <param name="shortTermCacheManager">Short term cache manager</param>
|
||||||
/// <param name="staticCacheManager">Cache manager</param>
|
/// <param name="staticCacheManager">Cache manager</param>
|
||||||
public AuctionService(AuctionDbContext ctx, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, IWorkContext workContext)
|
public AuctionService(AuctionDbContext ctx, IRepository<Auction> auctionRepository, IRepository<ProductToAuctionMapping> productToAuctionRepository, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, IWorkContext workContext)
|
||||||
{
|
{
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
//_customerBidRepository = customerBidRepository;
|
//_customerBidRepository = customerBidRepository;
|
||||||
//_auctionRepository = auctionRepository;
|
//_auctionRepository = auctionRepository;
|
||||||
|
_productToAuctionRepository = productToAuctionRepository;
|
||||||
_shortTermCacheManager = shortTermCacheManager;
|
_shortTermCacheManager = shortTermCacheManager;
|
||||||
_staticCacheManager = staticCacheManager;
|
_staticCacheManager = staticCacheManager;
|
||||||
_workContext = workContext;
|
_workContext = workContext;
|
||||||
|
|
@ -170,6 +171,23 @@ public class AuctionService : IAuctionService
|
||||||
{
|
{
|
||||||
return new AuctionBidDto(await _ctx.AuctionBids.GetByIdAsync(auctionBidId));
|
return new AuctionBidDto(await _ctx.AuctionBids.GetByIdAsync(auctionBidId));
|
||||||
}
|
}
|
||||||
|
public async Task<bool> AssignProductToAuctionAsync(int productId, int auctionId)
|
||||||
|
{
|
||||||
|
var auction = await _ctx.Auctions.GetByIdAsync(auctionId);
|
||||||
|
if (auction == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var mapping = new ProductToAuctionMapping
|
||||||
|
{
|
||||||
|
ProductId = productId,
|
||||||
|
AuctionId = auctionId
|
||||||
|
};
|
||||||
|
|
||||||
|
await _productToAuctionRepository.InsertAsync(mapping);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#endregion Dtos
|
#endregion Dtos
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Nop.Core;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Nop.Core;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||||
|
|
||||||
|
|
@ -32,4 +33,6 @@ public interface IAuctionService
|
||||||
Task InsertAuctionAsync(Auction auction);
|
Task InsertAuctionAsync(Auction auction);
|
||||||
|
|
||||||
Task<IList<Auction>> GetAllAuctionsAsync();
|
Task<IList<Auction>> GetAllAuctionsAsync();
|
||||||
|
|
||||||
|
Task<bool> AssignProductToAuctionAsync(int productId, int auctionId);
|
||||||
}
|
}
|
||||||
|
|
@ -34,46 +34,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Services
|
||||||
{
|
{
|
||||||
public class MyProductModelFactory : ProductModelFactory
|
public class MyProductModelFactory : ProductModelFactory
|
||||||
{
|
{
|
||||||
protected readonly CaptchaSettings _captchaSettings;
|
|
||||||
protected readonly CatalogSettings _catalogSettings;
|
|
||||||
protected readonly CustomerSettings _customerSettings;
|
|
||||||
protected readonly ICategoryService _categoryService;
|
|
||||||
protected readonly ICurrencyService _currencyService;
|
|
||||||
protected readonly ICustomerService _customerService;
|
|
||||||
protected readonly IDateRangeService _dateRangeService;
|
|
||||||
protected readonly IDateTimeHelper _dateTimeHelper;
|
|
||||||
protected readonly IDownloadService _downloadService;
|
|
||||||
protected readonly IGenericAttributeService _genericAttributeService;
|
|
||||||
protected readonly IJsonLdModelFactory _jsonLdModelFactory;
|
|
||||||
protected readonly ILocalizationService _localizationService;
|
|
||||||
protected readonly IManufacturerService _manufacturerService;
|
|
||||||
protected readonly IPermissionService _permissionService;
|
|
||||||
protected readonly IPictureService _pictureService;
|
|
||||||
protected readonly IPriceCalculationService _priceCalculationService;
|
|
||||||
protected readonly IPriceFormatter _priceFormatter;
|
|
||||||
protected readonly IProductAttributeParser _productAttributeParser;
|
|
||||||
protected readonly IProductAttributeService _productAttributeService;
|
|
||||||
protected readonly IProductService _productService;
|
|
||||||
protected readonly IProductTagService _productTagService;
|
|
||||||
protected readonly IProductTemplateService _productTemplateService;
|
|
||||||
protected readonly IReviewTypeService _reviewTypeService;
|
|
||||||
protected readonly IShoppingCartService _shoppingCartService;
|
|
||||||
protected readonly ISpecificationAttributeService _specificationAttributeService;
|
|
||||||
protected readonly IStaticCacheManager _staticCacheManager;
|
|
||||||
protected readonly IStoreContext _storeContext;
|
|
||||||
protected readonly IStoreService _storeService;
|
|
||||||
protected readonly IShoppingCartModelFactory _shoppingCartModelFactory;
|
|
||||||
protected readonly ITaxService _taxService;
|
|
||||||
protected readonly IUrlRecordService _urlRecordService;
|
|
||||||
protected readonly IVendorService _vendorService;
|
|
||||||
protected readonly IVideoService _videoService;
|
|
||||||
protected readonly IWebHelper _webHelper;
|
|
||||||
protected readonly IWorkContext _workContext;
|
|
||||||
protected readonly MediaSettings _mediaSettings;
|
|
||||||
protected readonly OrderSettings _orderSettings;
|
|
||||||
protected readonly SeoSettings _seoSettings;
|
|
||||||
protected readonly ShippingSettings _shippingSettings;
|
|
||||||
protected readonly VendorSettings _vendorSettings;
|
|
||||||
private static readonly char[] _separator = [','];
|
private static readonly char[] _separator = [','];
|
||||||
|
|
||||||
public MyProductModelFactory(CaptchaSettings captchaSettings,
|
public MyProductModelFactory(CaptchaSettings captchaSettings,
|
||||||
|
|
@ -151,46 +112,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Services
|
||||||
vendorSettings
|
vendorSettings
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_captchaSettings = captchaSettings;
|
|
||||||
_catalogSettings = catalogSettings;
|
|
||||||
_customerSettings = customerSettings;
|
|
||||||
_categoryService = categoryService;
|
|
||||||
_currencyService = currencyService;
|
|
||||||
_customerService = customerService;
|
|
||||||
_dateRangeService = dateRangeService;
|
|
||||||
_dateTimeHelper = dateTimeHelper;
|
|
||||||
_downloadService = downloadService;
|
|
||||||
_genericAttributeService = genericAttributeService;
|
|
||||||
_jsonLdModelFactory = jsonLdModelFactory;
|
|
||||||
_localizationService = localizationService;
|
|
||||||
_manufacturerService = manufacturerService;
|
|
||||||
_permissionService = permissionService;
|
|
||||||
_pictureService = pictureService;
|
|
||||||
_priceCalculationService = priceCalculationService;
|
|
||||||
_priceFormatter = priceFormatter;
|
|
||||||
_productAttributeParser = productAttributeParser;
|
|
||||||
_productAttributeService = productAttributeService;
|
|
||||||
_productService = productService;
|
|
||||||
_productTagService = productTagService;
|
|
||||||
_productTemplateService = productTemplateService;
|
|
||||||
_reviewTypeService = reviewTypeService;
|
|
||||||
_shoppingCartService = shoppingCartService;
|
|
||||||
_specificationAttributeService = specificationAttributeService;
|
|
||||||
_staticCacheManager = staticCacheManager;
|
|
||||||
_storeContext = storeContext;
|
|
||||||
_storeService = storeService;
|
|
||||||
_shoppingCartModelFactory = shoppingCartModelFactory;
|
|
||||||
_taxService = taxService;
|
|
||||||
_urlRecordService = urlRecordService;
|
|
||||||
_vendorService = vendorService;
|
|
||||||
_webHelper = webHelper;
|
|
||||||
_workContext = workContext;
|
|
||||||
_mediaSettings = mediaSettings;
|
|
||||||
_orderSettings = orderSettings;
|
|
||||||
_seoSettings = seoSettings;
|
|
||||||
_shippingSettings = shippingSettings;
|
|
||||||
_vendorSettings = vendorSettings;
|
|
||||||
_videoService = videoService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<ProductDetailsModel> PrepareProductDetailsModelAsync(Product product,
|
public override async Task<ProductDetailsModel> PrepareProductDetailsModelAsync(Product product,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
@model string
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
@T("Plugins.Widgets.What3words.Address.Field.Label")
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
@Model
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
@ -3,33 +3,36 @@
|
||||||
|
|
||||||
@* @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(myObj) as String) *@
|
@* @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(myObj) as String) *@
|
||||||
<div class="bg-dark p-3">
|
<div class="bg-dark p-3">
|
||||||
<h3>Auction Public View Component</h3>
|
|
||||||
<p>@T("Plugins.Misc.AuctionPlugin.BidBox.Field.Label"):</p>
|
|
||||||
<p>DEBUG DATA:</p>
|
|
||||||
<p>@Model.ProductId</p>
|
|
||||||
<p>@Model.CustomerId</p>
|
|
||||||
<p>@Model.BasePrice</p>
|
|
||||||
<div class="d-flex justify-content-between mb-3">
|
<div class="d-flex justify-content-between mb-3">
|
||||||
|
<div>
|
||||||
|
<strong>Base Price:</strong>
|
||||||
|
<span class="value">
|
||||||
|
@String.Format("{0:c}", Model.BasePrice)
|
||||||
|
@* @(decimal?.Round(Model.BasePrice, 2, MidpointRounding.AwayFromZero)) *@
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<strong>Current Price:</strong>
|
<strong>Current Price:</strong>
|
||||||
<span class="value">@Model.CurrentPrice</span>
|
<span class="value">
|
||||||
|
@String.Format("{0:c}", Model.CurrentPrice)
|
||||||
|
@* @(decimal?.Round(Model.CurrentPrice, 2, MidpointRounding.AwayFromZero)) *@
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<strong>Bid Step:</strong>
|
<strong>Bid Step:</strong>
|
||||||
<span class="value">@Model.LicitStep</span>
|
<span class="value">@String.Format("{0:c}", Model.LicitStep)</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div>
|
||||||
|
|
||||||
<div class="d-flex align-items-center mb-3">
|
|
||||||
<label for="bidPrice" class="me-2">Your Bid Price:</label>
|
|
||||||
<input type="number" id="bidPrice" class="form-control w-25" value="@Model.BidPrice" min="@(Model.CurrentPrice + Model.LicitStep)">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button id="bidButton" class="btn btn-success">
|
<button id="bidButton" class="btn btn-success">
|
||||||
Place Bid
|
@* Bid @(decimal?.Round(@Model.BidPrice, 2, MidpointRounding.AwayFromZero)) *@
|
||||||
|
Bid @String.Format("{0:c}", Model.BidPrice)
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<button id="testButton" class="btn btn-success">
|
|
||||||
|
<button id="testButton" class="btn btn-success" style="display: none">
|
||||||
TestButton
|
TestButton
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
@ -72,8 +75,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$('#testButton').click(function ()
|
$('#testButton').click(function () {
|
||||||
{
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/Auction/RefreshAuctionWidget', // Controller endpoint
|
url: '/Auction/RefreshAuctionWidget', // Controller endpoint
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue