Merge branch 'main' of https://git2.aycode.com/Adam/Mango.Nop.Plugins
This commit is contained in:
commit
764173485b
|
|
@ -5,8 +5,10 @@ using Nop.Plugin.Misc.AuctionPlugin.Domains;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Hubs;
|
using Nop.Plugin.Misc.AuctionPlugin.Hubs;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
|
using Nop.Services.Logging;
|
||||||
using Nop.Web.Framework;
|
using Nop.Web.Framework;
|
||||||
using Nop.Web.Framework.Controllers;
|
using Nop.Web.Framework.Controllers;
|
||||||
|
using Nop.Web.Framework.Models.DataTables;
|
||||||
using Nop.Web.Framework.Mvc;
|
using Nop.Web.Framework.Mvc;
|
||||||
using Nop.Web.Framework.Mvc.Filters;
|
using Nop.Web.Framework.Mvc.Filters;
|
||||||
using System;
|
using System;
|
||||||
|
|
@ -24,6 +26,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers
|
||||||
|
|
||||||
private readonly IAnnouncementService _announcementService;
|
private readonly IAnnouncementService _announcementService;
|
||||||
private IHubContext<AuctionHub> _announcementHubContext;
|
private IHubContext<AuctionHub> _announcementHubContext;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -31,10 +34,12 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers
|
||||||
|
|
||||||
public AnnouncementController(
|
public AnnouncementController(
|
||||||
IAnnouncementService announcementService,
|
IAnnouncementService announcementService,
|
||||||
IHubContext<AuctionHub> announcementHubContext)
|
IHubContext<AuctionHub> announcementHubContext,
|
||||||
|
ILogger logger)
|
||||||
{
|
{
|
||||||
_announcementService = announcementService;
|
_announcementService = announcementService;
|
||||||
_announcementHubContext = announcementHubContext;
|
_announcementHubContext = announcementHubContext;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -92,7 +97,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers
|
||||||
model.Body = singleAnnouncement.Body;
|
model.Body = singleAnnouncement.Body;
|
||||||
model.IsActive = singleAnnouncement.IsActive;
|
model.IsActive = singleAnnouncement.IsActive;
|
||||||
|
|
||||||
return View("~/Plugins/Widget.LiveAnnouncement/Views/LiveAnnouncementView/Announcement.cshtml", model);
|
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/Announcement.cshtml", model);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,21 +109,36 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IActionResult AnnouncementList()
|
public async Task<IActionResult> AnnouncementList()
|
||||||
{
|
{
|
||||||
|
await _logger.InformationAsync("AnnouncementList called!");
|
||||||
var model = new AnnouncementViewModel();
|
var model = new AnnouncementViewModel();
|
||||||
return View("~/Plugins/Misc.Auction/Areas/Admin/Views/AnnouncementList.cshtml", model);
|
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/AnnouncementList.cshtml", model);
|
||||||
}
|
}
|
||||||
|
|
||||||
//[HttpPost]
|
[HttpPost]
|
||||||
//public IActionResult AnnouncementList()
|
//public async Task<IActionResult> GetAnnouncementList([FromBody] KendoGridRequestModel request)
|
||||||
|
public async Task<IActionResult> GetAnnouncementList()
|
||||||
|
{
|
||||||
|
//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 View();
|
return Ok(new DataTablesModel { Data = await _announcementService.GetAnnouncementsAsync() });
|
||||||
|
}
|
||||||
//}
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return BadRequest(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ using Nop.Plugin.Misc.AuctionPlugin;
|
||||||
using Nop.Services.Messages;
|
using Nop.Services.Messages;
|
||||||
using Nop.Services.Localization;
|
using Nop.Services.Localization;
|
||||||
using Nop.Services.Logging;
|
using Nop.Services.Logging;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers;
|
namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers;
|
||||||
|
|
||||||
|
|
@ -21,16 +23,18 @@ public class AuctionPluginAdminController : BasePluginController
|
||||||
private readonly INotificationService _notificationService;
|
private readonly INotificationService _notificationService;
|
||||||
private readonly ISettingService _settingService;
|
private readonly ISettingService _settingService;
|
||||||
private readonly AuctionSettings _auctionSettings;
|
private readonly AuctionSettings _auctionSettings;
|
||||||
|
private readonly IAuctionService _auctionService;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
//public AuctionPluginAdminController(SignalRservice signalRservice)
|
//public AuctionPluginAdminController(SignalRservice signalRservice)
|
||||||
public AuctionPluginAdminController(ILocalizationService localizationService, INotificationService notificationService, ISettingService settingService, AuctionSettings auctionSettings, ILogger logger)
|
public AuctionPluginAdminController(ILocalizationService localizationService, INotificationService notificationService, ISettingService settingService, AuctionSettings auctionSettings, ILogger logger, IAuctionService auctionService)
|
||||||
{
|
{
|
||||||
_localizationService = localizationService;
|
_localizationService = localizationService;
|
||||||
_notificationService = notificationService;
|
_notificationService = notificationService;
|
||||||
_settingService = settingService;
|
_settingService = settingService;
|
||||||
_auctionSettings = auctionSettings;
|
_auctionSettings = auctionSettings;
|
||||||
//_signalRservice = signalRservice;
|
//_signalRservice = signalRservice;
|
||||||
|
_auctionService = auctionService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,4 +83,37 @@ public class AuctionPluginAdminController : BasePluginController
|
||||||
// return Json(new { success = false, message = $"Error: {ex.Message}" });
|
// return Json(new { success = false, message = $"Error: {ex.Message}" });
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
public IActionResult GetAuctionViewModel()
|
||||||
|
{
|
||||||
|
var model = new AuctionViewModel();
|
||||||
|
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/Auction.cshtml", model);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<IActionResult> GetAuctionViewModel(AuctionViewModel viewModel)
|
||||||
|
{
|
||||||
|
Auction objOfAuctionDomain = new Auction();
|
||||||
|
objOfAuctionDomain.AuctionName = viewModel.AuctionName;
|
||||||
|
objOfAuctionDomain.AuctionType = viewModel.AuctionType;
|
||||||
|
objOfAuctionDomain.StartDateUtc = viewModel.StartDateUtc;
|
||||||
|
objOfAuctionDomain.EndDateUtc = viewModel.EndDateUtc;
|
||||||
|
objOfAuctionDomain.Closed = viewModel.Closed;
|
||||||
|
objOfAuctionDomain.Created = DateTime.UtcNow;
|
||||||
|
await _auctionService.InsertAuctionAsync(objOfAuctionDomain);
|
||||||
|
|
||||||
|
//if (viewModel.IsActive == true)
|
||||||
|
//{
|
||||||
|
// await _announcementHubContext.Clients.All.SendAsync("send", viewModel.Body.ToString());
|
||||||
|
//}
|
||||||
|
return RedirectToAction("AuctionList");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult TestPage()
|
||||||
|
{
|
||||||
|
var model = new TestPageViewModel();
|
||||||
|
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/Auction.cshtml", model);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||||
|
using Nop.Web.Framework.Models;
|
||||||
|
using Nop.Web.Framework.Mvc.ModelBinding;
|
||||||
|
|
||||||
|
namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models
|
||||||
|
{
|
||||||
|
public record AuctionViewModel : BaseNopModel
|
||||||
|
{
|
||||||
|
public string PageTitle { get; set; }
|
||||||
|
|
||||||
|
[NopResourceDisplayName("Name")]
|
||||||
|
public string AuctionName { get; set; }
|
||||||
|
public AuctionType AuctionType { get; set; }
|
||||||
|
|
||||||
|
public DateTime StartDateUtc { get; set; }
|
||||||
|
public DateTime? EndDateUtc { get; set; }
|
||||||
|
|
||||||
|
public bool Closed { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||||
|
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 TestPageViewModel : BaseNopModel
|
||||||
|
{
|
||||||
|
public string Title { get; set; }
|
||||||
|
public string Message { get; set; }
|
||||||
|
public Auction TestAuction { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
Create Announcement
|
Create Announcement
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<a href="/Admin/LiveAnnouncement/AnnouncementList" class="btn bg-olive">LiveAnnouncement</a>
|
<a href="/Admin/AnnouncementList" class="btn bg-olive">Announcements</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
@using Nop.Core.Infrastructure
|
@using Nop.Core.Infrastructure
|
||||||
@using Nop.Web.Framework
|
@using Nop.Web.Framework
|
||||||
|
|
||||||
|
|
||||||
@{
|
@{
|
||||||
var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
|
var defaultGridPageSize = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().DefaultGridPageSize;
|
||||||
var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;
|
var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;
|
||||||
|
|
@ -13,7 +14,7 @@
|
||||||
|
|
||||||
<div class="content-header clearfix">
|
<div class="content-header clearfix">
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<a href="../LiveAnnouncement/Announcement" class="btn bg-blue">
|
<a href="../GetAnnouncementViewModel" class="btn bg-blue">
|
||||||
<i class="fa fa-floppy-o"></i>
|
<i class="fa fa-floppy-o"></i>
|
||||||
Add
|
Add
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -25,87 +26,29 @@
|
||||||
<div class="panel-group">
|
<div class="panel-group">
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div id="Announcement-grid"></div>
|
|
||||||
<script>
|
|
||||||
$(document).ready(function () {
|
|
||||||
$("#Announcement-grid").kendoGrid({
|
|
||||||
dataSource: {
|
|
||||||
type: "json",
|
|
||||||
transport: {
|
|
||||||
read: {
|
|
||||||
url: "@Html.Raw(Url.Action("AnnouncementList", "LiveAnnouncement"))",
|
|
||||||
type: "POST",
|
|
||||||
dataType: "json",
|
|
||||||
data: addAntiForgeryToken
|
|
||||||
},
|
|
||||||
destroy: {
|
|
||||||
url: "@Html.Raw(Url.Action("Delete", "LiveAnnouncement"))",
|
|
||||||
type: "POST",
|
|
||||||
dataType: "json",
|
|
||||||
data: addAntiForgeryToken
|
|
||||||
}
|
|
||||||
},
|
|
||||||
schema: {
|
|
||||||
data: "Data",
|
|
||||||
total: "Total",
|
|
||||||
errors: "Errors",
|
|
||||||
model: {
|
|
||||||
id: "Id"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
error: function (e) {
|
@await Html.PartialAsync("Table", new DataTablesModel
|
||||||
display_kendoui_grid_error(e);
|
|
||||||
// Cancel the changes
|
|
||||||
this.cancelChanges();
|
|
||||||
},
|
|
||||||
|
|
||||||
pageSize: @(defaultGridPageSize),
|
|
||||||
serverPaging: true,
|
|
||||||
serverFiltering: true,
|
|
||||||
serverSorting: true
|
|
||||||
},
|
|
||||||
pageable: {
|
|
||||||
refresh: true,
|
|
||||||
pageSizes: [@(gridPageSizes)]
|
|
||||||
},
|
|
||||||
editable: {
|
|
||||||
confirmation: false,
|
|
||||||
mode: "inline"
|
|
||||||
},
|
|
||||||
scrollable: false,
|
|
||||||
columns: [{
|
|
||||||
field: "Name",
|
|
||||||
title: "Name",
|
|
||||||
width: 100
|
|
||||||
}, {
|
|
||||||
field: "Body",
|
|
||||||
title: "Body",
|
|
||||||
width: 100,
|
|
||||||
headerAttributes: { style: "text-align:center" },
|
|
||||||
attributes: { style: "text-align:center" }
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
field: "IsActive",
|
Name = "announcement-grid",
|
||||||
title: "IsActive",
|
UrlRead = new DataUrl("GetAnnouncementList", "Announcement"),
|
||||||
width: 100,
|
Paging = false,
|
||||||
headerAttributes: { style: "text-align:center" },
|
ColumnCollection = new List<ColumnProperty>
|
||||||
attributes: { style: "text-align:center" }
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: "Edite",
|
new ColumnProperty(nameof(Announcement.Name))
|
||||||
width: 100,
|
{
|
||||||
template: '<a href="Edit/#=Id#">@T("Admin.Common.Edit")</a>'
|
Title = "Name",
|
||||||
}, {
|
Width = "300"
|
||||||
command: { name: "destroy", text: "@T("Admin.Common.Delete")" },
|
},
|
||||||
title: "@T("Admin.Common.Delete")",
|
new ColumnProperty(nameof(Announcement.Body))
|
||||||
width: 100,
|
{
|
||||||
headerAttributes: { style: "text-align:center" },
|
Title = "Body",
|
||||||
attributes: { style: "text-align:center" }
|
Width = "400"
|
||||||
}]
|
}
|
||||||
});
|
}
|
||||||
});
|
})
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
@model AuctionViewModel
|
||||||
|
@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
|
||||||
|
Model.PageTitle = "Auctions page";
|
||||||
|
ViewBag.Title = Model.PageTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
@using (Html.BeginForm())
|
||||||
|
{
|
||||||
|
<div class="content-header clearfix">
|
||||||
|
<h1 class="pull-left">
|
||||||
|
Create Auction
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<div class="pull-right">
|
||||||
|
<button type="submit" class="btn bg-purple">
|
||||||
|
<i class="fa fa-file-pdf-o"></i>
|
||||||
|
Create Auction
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<a href="/Admin/AuctionList" class="btn bg-olive">Auctions</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<div class="form-horizontal">
|
||||||
|
<div class="panel-group">
|
||||||
|
<div class="panel panel-default panel-search">
|
||||||
|
<div class="panel-body">
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-3" style="text-align:center;">
|
||||||
|
|
||||||
|
@Html.LabelFor(model => model.AuctionName)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-8">
|
||||||
|
|
||||||
|
@Html.EditorFor(model => model.AuctionName)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-1">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-3" style="text-align:center;">
|
||||||
|
|
||||||
|
@Html.LabelFor(model => model.StartDateUtc)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-8">
|
||||||
|
@* <nop-editor asp-for="@Model.StartDateUtc" asp-template="DateTimePicker" /> *@
|
||||||
|
@Html.EditorFor(model => model.StartDateUtc)
|
||||||
|
</div>
|
||||||
|
<div class="col-md-1">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-md-3" style="text-align:center;">
|
||||||
|
|
||||||
|
@Html.LabelFor(model => model.Closed)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="col-md-8">
|
||||||
|
|
||||||
|
@Html.EditorFor(model => model.Closed)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-1">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -13,3 +13,5 @@
|
||||||
@using Nop.Core.Infrastructure
|
@using Nop.Core.Infrastructure
|
||||||
@using Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models;
|
@using Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models;
|
||||||
@using Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers;
|
@using Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Controllers;
|
||||||
|
@using Nop.Web.Framework.Models.DataTables
|
||||||
|
@using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities
|
||||||
|
|
@ -10,7 +10,7 @@ public static class AuctionDefaults
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the system name
|
/// Gets the system name
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string SystemName => "Misc.AuctionPlugin";
|
public static string SystemName => "AuctionPlugin";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the user agent used to request third-party services
|
/// Gets the user agent used to request third-party services
|
||||||
|
|
@ -27,6 +27,7 @@ public static class AuctionDefaults
|
||||||
/// </summary>
|
/// </summary>
|
||||||
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";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the name of autosuggest component
|
/// Gets the name of autosuggest component
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(widgetZone);
|
ArgumentNullException.ThrowIfNull(widgetZone);
|
||||||
|
|
||||||
if (widgetZone.Equals(PublicWidgetZones.ProductDetailsOverviewTop))
|
if (widgetZone.Equals(PublicWidgetZones.ProductPriceTop))
|
||||||
{
|
{
|
||||||
return typeof(AuctionPublicViewComponent);
|
return typeof(AuctionPublicViewComponent);
|
||||||
}
|
}
|
||||||
|
|
@ -116,11 +116,11 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
||||||
{
|
{
|
||||||
return Task.FromResult<IList<string>>(new List<string>
|
return Task.FromResult<IList<string>>(new List<string>
|
||||||
{
|
{
|
||||||
PublicWidgetZones.ProductDetailsOverviewTop,
|
PublicWidgetZones.ProductPriceTop,
|
||||||
PublicWidgetZones.OrderSummaryBillingAddress,
|
PublicWidgetZones.ProductDetailsBottom,
|
||||||
|
|
||||||
AdminWidgetZones.OrderBillingAddressDetailsBottom,
|
//AdminWidgetZones.OrderBillingAddressDetailsBottom,
|
||||||
AdminWidgetZones.OrderShippingAddressDetailsBottom
|
//AdminWidgetZones.OrderShippingAddressDetailsBottom
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,6 +140,8 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
||||||
rootNode.ChildNodes.Add(liveAnnouncementPluginNode);
|
rootNode.ChildNodes.Add(liveAnnouncementPluginNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
liveAnnouncementPluginNode.ChildNodes.Add(new SiteMapNode()
|
liveAnnouncementPluginNode.ChildNodes.Add(new SiteMapNode()
|
||||||
{
|
{
|
||||||
Title = await _localizationService.GetResourceAsync("Plugins.Configure"),
|
Title = await _localizationService.GetResourceAsync("Plugins.Configure"),
|
||||||
|
|
@ -149,6 +151,14 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
liveAnnouncementPluginNode.ChildNodes.Add(new SiteMapNode()
|
||||||
|
{
|
||||||
|
Title = await _localizationService.GetResourceAsync("Misc.Auction"),
|
||||||
|
Visible = true,
|
||||||
|
IconClass = "fa-dot-circle-o",
|
||||||
|
Url = "~/Admin/AuctionPluginAdmin/GetAuctionViewModel"
|
||||||
|
});
|
||||||
|
|
||||||
liveAnnouncementPluginNode.ChildNodes.Add(new SiteMapNode()
|
liveAnnouncementPluginNode.ChildNodes.Add(new SiteMapNode()
|
||||||
{
|
{
|
||||||
Title = await _localizationService.GetResourceAsync("Misc.Announcement"),
|
Title = await _localizationService.GetResourceAsync("Misc.Announcement"),
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using Nop.Core;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin;
|
using Nop.Plugin.Misc.AuctionPlugin;
|
||||||
using Nop.Services.Cms;
|
using Nop.Services.Cms;
|
||||||
using Nop.Services.Common;
|
using Nop.Services.Common;
|
||||||
|
using Nop.Services.Logging;
|
||||||
using Nop.Web.Framework.Components;
|
using Nop.Web.Framework.Components;
|
||||||
using Nop.Web.Framework.Infrastructure;
|
using Nop.Web.Framework.Infrastructure;
|
||||||
using Nop.Web.Models.Catalog;
|
using Nop.Web.Models.Catalog;
|
||||||
|
|
@ -20,6 +21,7 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
protected readonly IWidgetPluginManager _widgetPluginManager;
|
protected readonly IWidgetPluginManager _widgetPluginManager;
|
||||||
protected readonly IWorkContext _workContext;
|
protected readonly IWorkContext _workContext;
|
||||||
protected readonly AuctionSettings _auctionSettings;
|
protected readonly AuctionSettings _auctionSettings;
|
||||||
|
protected readonly ILogger _logger;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
@ -29,13 +31,15 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
IGenericAttributeService genericAttributeService,
|
IGenericAttributeService genericAttributeService,
|
||||||
IWidgetPluginManager widgetPluginManager,
|
IWidgetPluginManager widgetPluginManager,
|
||||||
IWorkContext workContext,
|
IWorkContext workContext,
|
||||||
AuctionSettings auctionSettings)
|
AuctionSettings auctionSettings,
|
||||||
|
ILogger logger)
|
||||||
{
|
{
|
||||||
_addressService = addressService;
|
_addressService = addressService;
|
||||||
_genericAttributeService = genericAttributeService;
|
_genericAttributeService = genericAttributeService;
|
||||||
_widgetPluginManager = widgetPluginManager;
|
_widgetPluginManager = widgetPluginManager;
|
||||||
_workContext = workContext;
|
_workContext = workContext;
|
||||||
_auctionSettings = auctionSettings;
|
_auctionSettings = auctionSettings;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
@ -53,25 +57,41 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
||||||
{
|
{
|
||||||
|
await _logger.InformationAsync("WidgetViewComponent called");
|
||||||
|
|
||||||
//ensure that what3words widget is active and enabled
|
//ensure that what3words widget is active and enabled
|
||||||
var customer = await _workContext.GetCurrentCustomerAsync();
|
var customer = await _workContext.GetCurrentCustomerAsync();
|
||||||
|
await _logger.InformationAsync($"WidgetViewComponent customer: {customer.Email}");
|
||||||
|
|
||||||
if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName, customer))
|
if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName, customer))
|
||||||
return Content(string.Empty);
|
return Content(string.Empty);
|
||||||
|
|
||||||
if (!_auctionSettings.Enabled)
|
await _logger.InformationAsync("WidgetViewComponent widget active");
|
||||||
return Content(string.Empty);
|
|
||||||
|
//if (!_auctionSettings.Enabled)
|
||||||
|
// return Content(string.Empty);
|
||||||
|
|
||||||
var productDetailsModel = additionalData as ProductDetailsModel;
|
var productDetailsModel = additionalData as ProductDetailsModel;
|
||||||
|
|
||||||
if (productDetailsModel is null)
|
await _logger.InformationAsync($"WidgetViewComponent product: {productDetailsModel.Name}");
|
||||||
|
|
||||||
|
//if (productDetailsModel is null)
|
||||||
|
//{
|
||||||
|
|
||||||
|
// await _logger.InformationAsync("WidgetViewComponent productdetailsmodel is null");
|
||||||
|
// return Content(string.Empty);
|
||||||
|
//}
|
||||||
|
|
||||||
|
if (!widgetZone.Equals(PublicWidgetZones.ProductPriceTop))
|
||||||
|
{
|
||||||
|
await _logger.InformationAsync($"WidgetViewComponent is NOT in ProductDetailsTop now {widgetZone}");
|
||||||
return Content(string.Empty);
|
return Content(string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
var productId = 0;
|
await _logger.InformationAsync("WidgetViewComponent called II");
|
||||||
if (widgetZone.Equals(PublicWidgetZones.ProductDetailsTop))
|
|
||||||
productId = productDetailsModel.Id;
|
|
||||||
|
|
||||||
|
|
||||||
return View("~/Plugins/Widgets.What3words/Views/PublicProductBidBox.cshtml", productId.ToString());
|
return View("~/Plugins/Misc.AuctionPlugin/Views/PublicProductBidBox.cshtml", productDetailsModel.Id.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -49,16 +49,16 @@ public class AuctionViewComponent : NopViewComponent
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
||||||
{
|
{
|
||||||
|
await _logger.InformationAsync("Auction widget called");
|
||||||
|
|
||||||
//ensure that a widget is active and enabled
|
//ensure that a widget is active and enabled
|
||||||
var customer = await _workContext.GetCurrentCustomerAsync();
|
var customer = await _workContext.GetCurrentCustomerAsync();
|
||||||
|
|
||||||
if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName, customer))
|
//if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName, customer))
|
||||||
return Content(string.Empty);
|
// return Content(string.Empty);
|
||||||
|
|
||||||
if (!_auctionSettings.Enabled)
|
//if (!_auctionSettings.Enabled)
|
||||||
return Content(string.Empty);
|
// return Content(string.Empty);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(_auctionSettings.SomeText))
|
if (string.IsNullOrEmpty(_auctionSettings.SomeText))
|
||||||
{
|
{
|
||||||
|
|
@ -74,7 +74,7 @@ public class AuctionViewComponent : NopViewComponent
|
||||||
//}
|
//}
|
||||||
var model = new AuctionPublicInfoModel();
|
var model = new AuctionPublicInfoModel();
|
||||||
|
|
||||||
if (!widgetZone.Equals(PublicWidgetZones.ProductDetailsTop))
|
if (widgetZone.Equals(PublicWidgetZones.ProductDetailsBottom))
|
||||||
{
|
{
|
||||||
|
|
||||||
model.Message = $"Auction plugin is active, setting = {_auctionSettings.SomeText}, productId = {((ProductDetailsModel)additionalData).Name}";
|
model.Message = $"Auction plugin is active, setting = {_auctionSettings.SomeText}, productId = {((ProductDetailsModel)additionalData).Name}";
|
||||||
|
|
@ -87,7 +87,7 @@ public class AuctionViewComponent : NopViewComponent
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return View("~/Plugins/Widgets.AuctionPlugin/Views/PublicInfo.cshtml", model);
|
return View("~/Plugins/Misc.AuctionPlugin/Views/PublicInfo.cshtml", model);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,10 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
|
||||||
endpointRouteBuilder.MapControllerRoute(name: AuctionDefaults.AnnouncementListRouteName,
|
endpointRouteBuilder.MapControllerRoute(name: AuctionDefaults.AnnouncementListRouteName,
|
||||||
pattern: "Admin/Announcement/AnnouncementList",
|
pattern: "Admin/Announcement/AnnouncementList",
|
||||||
defaults: new { controller = "Announcement", action = "AnnouncementList"});
|
defaults: new { controller = "Announcement", action = "AnnouncementList"});
|
||||||
|
|
||||||
|
endpointRouteBuilder.MapControllerRoute(name: AuctionDefaults.AuctionRouteName,
|
||||||
|
pattern: "Admin/AuctionPlugin/GetAuctionViewModel",
|
||||||
|
defaults: new { controller = "AuctionPluginAdmin", action = "GetAuctionViewModel" });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Remove="Areas\Admin\Views\Auction.cshtml" />
|
||||||
<None Remove="logo.jpg" />
|
<None Remove="logo.jpg" />
|
||||||
<None Remove="plugin.json" />
|
<None Remove="plugin.json" />
|
||||||
<None Remove="Views\AdminProductAuctionSettingsBox.cshtml" />
|
<None Remove="Views\AdminProductAuctionSettingsBox.cshtml" />
|
||||||
|
|
@ -27,6 +28,9 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="Areas\Admin\Views\Auction.cshtml">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="logo.jpg">
|
<Content Include="logo.jpg">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ public class AuctionService : IAuctionService
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
protected readonly IRepository<AuctionBid> _customerBidRepository;
|
protected readonly IRepository<AuctionBid> _customerBidRepository;
|
||||||
|
protected readonly IRepository<Auction> _auctionRepository;
|
||||||
protected readonly IShortTermCacheManager _shortTermCacheManager;
|
protected readonly IShortTermCacheManager _shortTermCacheManager;
|
||||||
protected readonly IStaticCacheManager _staticCacheManager;
|
protected readonly IStaticCacheManager _staticCacheManager;
|
||||||
|
|
||||||
|
|
@ -40,11 +41,14 @@ public class AuctionService : IAuctionService
|
||||||
/// <param name="customerBidRepository">Store pickup point repository</param>
|
/// <param name="customerBidRepository">Store pickup point repository</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(IRepository<AuctionBid> customerBidRepository,
|
public AuctionService(
|
||||||
|
IRepository<AuctionBid> customerBidRepository,
|
||||||
|
IRepository<Auction> auctionRepository,
|
||||||
IShortTermCacheManager shortTermCacheManager,
|
IShortTermCacheManager shortTermCacheManager,
|
||||||
IStaticCacheManager staticCacheManager)
|
IStaticCacheManager staticCacheManager)
|
||||||
{
|
{
|
||||||
_customerBidRepository = customerBidRepository;
|
_customerBidRepository = customerBidRepository;
|
||||||
|
_auctionRepository = auctionRepository;
|
||||||
_shortTermCacheManager = shortTermCacheManager;
|
_shortTermCacheManager = shortTermCacheManager;
|
||||||
_staticCacheManager = staticCacheManager;
|
_staticCacheManager = staticCacheManager;
|
||||||
}
|
}
|
||||||
|
|
@ -106,5 +110,13 @@ public class AuctionService : IAuctionService
|
||||||
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region auctions
|
||||||
|
public virtual async Task InsertAuctionAsync(Auction auction)
|
||||||
|
{
|
||||||
|
await _auctionRepository.InsertAsync(auction, false);
|
||||||
|
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
@ -21,15 +21,13 @@ public interface IAuctionService
|
||||||
/// </returns>
|
/// </returns>
|
||||||
Task<IPagedList<AuctionBid>> GetAllBidsAsync(int customerId = 0, int pageIndex = 0, int pageSize = int.MaxValue);
|
Task<IPagedList<AuctionBid>> GetAllBidsAsync(int customerId = 0, int pageIndex = 0, int pageSize = int.MaxValue);
|
||||||
|
|
||||||
|
|
||||||
Task<AuctionBid> GetBidByIdAsync(int bidId);
|
Task<AuctionBid> GetBidByIdAsync(int bidId);
|
||||||
|
|
||||||
|
|
||||||
Task InsertBidAsync(AuctionBid auctionBid);
|
Task InsertBidAsync(AuctionBid auctionBid);
|
||||||
|
|
||||||
|
|
||||||
Task UpdateBidAsync(AuctionBid auctionBid);
|
Task UpdateBidAsync(AuctionBid auctionBid);
|
||||||
|
|
||||||
|
|
||||||
Task DeleteBidAsync(AuctionBid pickupPoint);
|
Task DeleteBidAsync(AuctionBid pickupPoint);
|
||||||
|
|
||||||
|
Task InsertAuctionAsync(Auction auction);
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
@model AuctionPublicInfoModel
|
@model AuctionPublicInfoModel
|
||||||
|
|
||||||
<div>
|
<div class="bg-dark">
|
||||||
<label for="w3w">@T("Plugins.Widgets.AuctionPLugin.Label"):</label>
|
<h3>Auction viewcomponent</h3>
|
||||||
|
<label for="w3w">@T("Plugins.Misc.AuctionPLugin.Label"):</label>
|
||||||
<div class="">
|
<div class="">
|
||||||
<p>@Model.Message</p>
|
<p>General widget info: @Model.Message</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
@model string
|
@model string
|
||||||
|
|
||||||
<li class="custom-value">
|
<div class="bg-dark">
|
||||||
|
<h3>Auction Public Viewcomponent</h3>
|
||||||
<span class="label">
|
<span class="label">
|
||||||
@T("Plugins.Misc.AuctionPlugin.BidBox.Field.Label"):
|
@T("Plugins.Misc.AuctionPlugin.BidBox.Field.Label"):
|
||||||
</span>
|
</span>
|
||||||
<span class="value">
|
<span class="value">
|
||||||
@(Model)
|
@(Model)
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue