AuctionPage
This commit is contained in:
parent
b4e8b97504
commit
e76764a08d
|
|
@ -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; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models
|
|
||||||
{
|
|
||||||
public class KendoGridRequestModel
|
|
||||||
{
|
|
||||||
// Page number
|
|
||||||
public int Page { get; set; } = 1;
|
|
||||||
|
|
||||||
// Page size (number of items per page)
|
|
||||||
public int PageSize { get; set; } = 10;
|
|
||||||
|
|
||||||
// Field to sort by
|
|
||||||
public string SortField { get; set; }
|
|
||||||
|
|
||||||
// Sort direction (e.g., "asc" or "desc")
|
|
||||||
public string SortDirection { get; set; }
|
|
||||||
|
|
||||||
// Optional: Filtering parameters, can be customized to fit your needs
|
|
||||||
public string FilterField { get; set; }
|
|
||||||
public string FilterValue { 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>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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"),
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
@ -20,16 +20,14 @@ public interface IAuctionService
|
||||||
/// The task result contains the bids
|
/// The task result contains the bids
|
||||||
/// </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);
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue