auction improvements

This commit is contained in:
Loretta 2024-11-15 06:15:34 +01:00
parent 56474e1bf6
commit 8af9b95fc5
10 changed files with 63 additions and 21 deletions

View File

@ -110,10 +110,13 @@ public class AuctionPluginAdminController : BasePluginController
} }
public IActionResult TestPage() public async Task<IActionResult> TestPage()
{ {
var model = new TestPageViewModel(); var model = new TestPageViewModel();
model.Message = "Teszt üzenet";
var auctions = await _auctionService.GetAllAuctionsAsync();
model.Message = $"Teszt üzenet; Auctions count: {auctions.Count}";
return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/TestPage.cshtml", model); return View("~/Plugins/Misc.AuctionPlugin/Areas/Admin/Views/TestPage.cshtml", model);
} }

View File

@ -13,5 +13,6 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models
public string Title { get; set; } public string Title { get; set; }
public string Message { get; set; } public string Message { get; set; }
public Auction TestAuction { get; set; } public Auction TestAuction { get; set; }
} }
} }

View File

@ -116,7 +116,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin
{ {
return Task.FromResult<IList<string>>(new List<string> return Task.FromResult<IList<string>>(new List<string>
{ {
PublicWidgetZones.ProductPriceTop, PublicWidgetZones.ProductDetailsInsideOverviewButtonsBefore,
PublicWidgetZones.ProductDetailsBottom, PublicWidgetZones.ProductDetailsBottom,
//AdminWidgetZones.OrderBillingAddressDetailsBottom, //AdminWidgetZones.OrderBillingAddressDetailsBottom,

View File

@ -1,4 +1,5 @@
using Nop.Core.Caching; using Mango.Nop.Core.Repositories;
using Nop.Core.Caching;
using Nop.Core.Configuration; using Nop.Core.Configuration;
using Nop.Core.Events; using Nop.Core.Events;
using Nop.Data; using Nop.Data;
@ -6,7 +7,7 @@ using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer; namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
public class AuctionBidDbTable: EntityRepository<AuctionBid> public class AuctionBidDbTable: MgDbTableBase<AuctionBid>
{ {
public AuctionBidDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings) public AuctionBidDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
{ {

View File

@ -1,6 +1,7 @@
using Mango.Nop.Core.Repositories; using Mango.Nop.Core.Repositories;
using Nop.Data; using Nop.Data;
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities; using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
using System;
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer; namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
@ -8,4 +9,23 @@ public class AuctionDbContext : MgDbContextBase, IAuctionDbSet<AuctionDbTable>,
{ {
public AuctionDbTable Auctions { get; set; } public AuctionDbTable Auctions { get; set; }
public AuctionBidDbTable AuctionBids { get; set; } public AuctionBidDbTable AuctionBids { get; set; }
public EntityRepository<Auction> Auctions2 { get; set; }
public IRepository<AuctionBid> AuctionBids2 { get; set; }
public AuctionDbContext(INopDataProvider dataProvider, AuctionDbTable auctionDbTable, AuctionBidDbTable auctionBidDbTable) : base(dataProvider)
{
Auctions = auctionDbTable;
AuctionBids = auctionBidDbTable;
//Auctions.Table
var auctions = DataProvider.GetTable<Auction>().Where(x => x.Closed);
}
//public AuctionDbContext(IRepository<Auction> _auctionRepository, IRepository<AuctionBid> _auctionBidRepository)
//{
// Auctions2 = _auctionRepository as EntityRepository<Auction>;
// AuctionBids2 = _auctionBidRepository;
//}
} }

View File

@ -1,4 +1,6 @@
using Nop.Core.Caching; using Mango.Nop.Core.Entities;
using Mango.Nop.Core.Repositories;
using Nop.Core.Caching;
using Nop.Core.Configuration; using Nop.Core.Configuration;
using Nop.Core.Events; using Nop.Core.Events;
using Nop.Data; using Nop.Data;
@ -6,7 +8,7 @@ using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer; namespace Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
public class AuctionDbTable: EntityRepository<Auction> public class AuctionDbTable: MgDbTableBase<Auction>
{ {
public AuctionDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings) public AuctionDbTable(IEventPublisher eventPublisher, INopDataProvider dataProvider, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager, AppSettings appSettings) : base(eventPublisher, dataProvider, shortTermCacheManager, staticCacheManager, appSettings)
{ {

View File

@ -7,6 +7,8 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Domains.Entities
{ {
public class AuctionBid : EntityBase, ITimeStampInfo//, ISoftRemoveEntityInt public class AuctionBid : EntityBase, ITimeStampInfo//, ISoftRemoveEntityInt
{ {
public int ProductAuctionMappingId { get; set; }
public int CustomerId { get; set; } public int CustomerId { get; set; }
public int ProductId { get; set; } public int ProductId { get; set; }

View File

@ -8,6 +8,7 @@ using Nop.Core;
using Nop.Core.Caching; using Nop.Core.Caching;
using Nop.Core.Infrastructure; using Nop.Core.Infrastructure;
using Nop.Data; using Nop.Data;
using Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
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.Catalog; using Nop.Services.Catalog;
@ -51,6 +52,10 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
services.AddScoped<IProductAttributeService, ProductAttributeService>(); services.AddScoped<IProductAttributeService, ProductAttributeService>();
services.AddScoped<UrlHelperFactory>(); services.AddScoped<UrlHelperFactory>();
services.AddScoped<IActionContextAccessor, ActionContextAccessor>(); services.AddScoped<IActionContextAccessor, ActionContextAccessor>();
services.AddScoped<AuctionDbTable>();
services.AddScoped<AuctionBidDbTable>();
services.AddScoped<AuctionDbContext>();
} }
/// <summary> /// <summary>

View File

@ -2,6 +2,7 @@
using Nop.Core.Caching; using Nop.Core.Caching;
using Nop.Data; using Nop.Data;
using Nop.Plugin.Misc.AuctionPlugin.Domains; using Nop.Plugin.Misc.AuctionPlugin.Domains;
using Nop.Plugin.Misc.AuctionPlugin.Domains.DataLayer;
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities; using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
namespace Nop.Plugin.Misc.AuctionPlugin.Services; namespace Nop.Plugin.Misc.AuctionPlugin.Services;
@ -26,8 +27,9 @@ public class AuctionService : IAuctionService
#region Fields #region Fields
protected readonly IRepository<AuctionBid> _customerBidRepository; protected readonly AuctionDbContext _ctx;
protected readonly IRepository<Auction> _auctionRepository; //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;
@ -41,14 +43,12 @@ 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( public AuctionService(AuctionDbContext ctx, IShortTermCacheManager shortTermCacheManager, IStaticCacheManager staticCacheManager)
IRepository<AuctionBid> customerBidRepository,
IRepository<Auction> auctionRepository,
IShortTermCacheManager shortTermCacheManager,
IStaticCacheManager staticCacheManager)
{ {
_customerBidRepository = customerBidRepository; _ctx = ctx;
_auctionRepository = auctionRepository; //_customerBidRepository = customerBidRepository;
//_auctionRepository = auctionRepository;
_shortTermCacheManager = shortTermCacheManager; _shortTermCacheManager = shortTermCacheManager;
_staticCacheManager = staticCacheManager; _staticCacheManager = staticCacheManager;
} }
@ -84,18 +84,18 @@ public class AuctionService : IAuctionService
public virtual async Task<AuctionBid> GetBidByIdAsync(int bidId) public virtual async Task<AuctionBid> GetBidByIdAsync(int bidId)
{ {
return await _customerBidRepository.GetByIdAsync(bidId); return await _ctx.AuctionBids.GetByIdAsync(bidId);
} }
public virtual async Task InsertBidAsync(AuctionBid auctionBid) public virtual async Task InsertBidAsync(AuctionBid auctionBid)
{ {
await _customerBidRepository.InsertAsync(auctionBid, false); await _ctx.AuctionBids.InsertAsync(auctionBid, false);
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY); await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
} }
public virtual async Task UpdateBidAsync(AuctionBid auctionBid) public virtual async Task UpdateBidAsync(AuctionBid auctionBid)
{ {
await _customerBidRepository.UpdateAsync(auctionBid, false); await _ctx.AuctionBids.UpdateAsync(auctionBid, false);
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY); await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
} }
@ -106,16 +106,22 @@ public class AuctionService : IAuctionService
/// <returns>A task that represents the asynchronous operation</returns> /// <returns>A task that represents the asynchronous operation</returns>
public virtual async Task DeleteBidAsync(AuctionBid pickupPoint) public virtual async Task DeleteBidAsync(AuctionBid pickupPoint)
{ {
await _customerBidRepository.DeleteAsync(pickupPoint, false); await _ctx.AuctionBids.DeleteAsync(pickupPoint, false);
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY); await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
} }
#region auctions #region auctions
public virtual async Task InsertAuctionAsync(Auction auction) public virtual async Task InsertAuctionAsync(Auction auction)
{ {
await _auctionRepository.InsertAsync(auction, false); await _ctx.Auctions.InsertAsync(auction, false);
await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY); await _staticCacheManager.RemoveByPrefixAsync(AUCTION_PATTERN_KEY);
} }
public async Task<List<Auction>> GetAllAuctionsAsync()
{
return (await _ctx.Auctions.GetAllAsync(auctions => auctions.OrderByDescending(x => x.StartDateUtc), _ => default)).ToList();
}
#endregion #endregion
#endregion #endregion

View File

@ -30,4 +30,6 @@ public interface IAuctionService
Task DeleteBidAsync(AuctionBid pickupPoint); Task DeleteBidAsync(AuctionBid pickupPoint);
Task InsertAuctionAsync(Auction auction); Task InsertAuctionAsync(Auction auction);
Task<List<Auction>> GetAllAuctionsAsync();
} }