improvements, fixes, etc...
This commit is contained in:
parent
5970cfb0a0
commit
1c1bb07fa6
|
|
@ -4,11 +4,10 @@ using Microsoft.AspNetCore.Mvc.Routing;
|
||||||
using Nop.Core;
|
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.Misc.AuctionPlugin.Areas.Admin.Components;
|
using Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Components;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Components;
|
||||||
|
|
||||||
//using Nop.Plugin.Misc.AuctionPlugin.Components;
|
//using Nop.Plugin.Misc.AuctionPlugin.Components;
|
||||||
using Nop.Plugin.Widgets.AuctionPlugin.Components;
|
|
||||||
using Nop.Services.Catalog;
|
using Nop.Services.Catalog;
|
||||||
using Nop.Services.Cms;
|
using Nop.Services.Cms;
|
||||||
using Nop.Services.Common;
|
using Nop.Services.Common;
|
||||||
|
|
@ -102,7 +101,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(widgetZone);
|
ArgumentNullException.ThrowIfNull(widgetZone);
|
||||||
|
|
||||||
if (widgetZone.Equals(PublicWidgetZones.ProductDetailsAfterPictures))
|
if (widgetZone.Equals(PublicWidgetZones.ProductDetailsOverviewTop))
|
||||||
{
|
{
|
||||||
return typeof(AuctionPublicViewComponent);
|
return typeof(AuctionPublicViewComponent);
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +128,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin
|
||||||
{
|
{
|
||||||
return Task.FromResult<IList<string>>(new List<string>
|
return Task.FromResult<IList<string>>(new List<string>
|
||||||
{
|
{
|
||||||
PublicWidgetZones.ProductDetailsAfterPictures,
|
PublicWidgetZones.ProductDetailsOverviewTop,
|
||||||
PublicWidgetZones.ProductDetailsBottom,
|
PublicWidgetZones.ProductDetailsBottom,
|
||||||
PublicWidgetZones.HeaderAfter,
|
PublicWidgetZones.HeaderAfter,
|
||||||
AdminWidgetZones.ProductDetailsButtons
|
AdminWidgetZones.ProductDetailsButtons
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Nop.Core;
|
using Nop.Core;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin;
|
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Models;
|
using Nop.Plugin.Misc.AuctionPlugin.Models;
|
||||||
using Nop.Services.Cms;
|
using Nop.Services.Cms;
|
||||||
using Nop.Services.Common;
|
using Nop.Services.Common;
|
||||||
|
|
@ -8,10 +7,8 @@ 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;
|
||||||
using Nop.Web.Models.Order;
|
|
||||||
using Nop.Web.Models.ShoppingCart;
|
|
||||||
|
|
||||||
namespace Nop.Plugin.AuctionPlugin.Components;
|
namespace Nop.Plugin.Misc.AuctionPlugin.Components;
|
||||||
|
|
||||||
public class AuctionPublicViewComponent : NopViewComponent
|
public class AuctionPublicViewComponent : NopViewComponent
|
||||||
{
|
{
|
||||||
|
|
@ -85,7 +82,7 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
// return Content(string.Empty);
|
// return Content(string.Empty);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (!widgetZone.Equals(PublicWidgetZones.ProductDetailsAfterPictures))
|
if (!widgetZone.Equals(PublicWidgetZones.ProductDetailsOverviewTop))
|
||||||
{
|
{
|
||||||
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);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Nop.Core;
|
using Nop.Core;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin;
|
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Models;
|
using Nop.Plugin.Misc.AuctionPlugin.Models;
|
||||||
using Nop.Services.Cms;
|
using Nop.Services.Cms;
|
||||||
using Nop.Services.Logging;
|
using Nop.Services.Logging;
|
||||||
|
|
@ -8,7 +7,7 @@ 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;
|
||||||
|
|
||||||
namespace Nop.Plugin.Widgets.AuctionPlugin.Components;
|
namespace Nop.Plugin.Misc.AuctionPlugin.Components;
|
||||||
|
|
||||||
public class AuctionViewComponent : NopViewComponent
|
public class AuctionViewComponent : NopViewComponent
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Nop.Core;
|
using Nop.Core;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin;
|
|
||||||
using Nop.Services.Cms;
|
using Nop.Services.Cms;
|
||||||
using Nop.Services.Logging;
|
using Nop.Services.Logging;
|
||||||
using Nop.Web.Framework.Components;
|
using Nop.Web.Framework.Components;
|
||||||
using Nop.Web.Framework.Infrastructure;
|
using Nop.Web.Framework.Infrastructure;
|
||||||
|
|
||||||
|
namespace Nop.Plugin.Misc.AuctionPlugin.Components
|
||||||
namespace Nop.Plugin.AuctionPlugin.Components
|
|
||||||
{
|
{
|
||||||
|
|
||||||
[ViewComponent(Name = "LiveAnnouncement")]
|
[ViewComponent(Name = "LiveAnnouncement")]
|
||||||
|
|
|
||||||
|
|
@ -18,5 +18,4 @@ public class AuctionDbTable: MgDbTableBase<Auction>
|
||||||
{
|
{
|
||||||
return GetAllAsync(auctions => auctions.OrderByDescending(x => x.StartDateUtc), _ => default);
|
return GetAllAsync(auctions => auctions.OrderByDescending(x => x.StartDateUtc), _ => default);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -10,8 +10,10 @@ public interface IProductToAuctionDtoBase : IMgModelDtoBase
|
||||||
|
|
||||||
public AuctionStatus AuctionStatus { get; set; }
|
public AuctionStatus AuctionStatus { get; set; }
|
||||||
|
|
||||||
public int StartingPrice { get; set; }
|
public decimal StartingPrice { get; set; }
|
||||||
public int BidPrice { get; set; }
|
public decimal BidPrice { get; set; }
|
||||||
|
|
||||||
public int BidAmount { get; set; }
|
public int ProductAmount { get; set; }
|
||||||
|
|
||||||
|
public int SortIndex { get; set; }
|
||||||
}
|
}
|
||||||
|
|
@ -10,9 +10,10 @@ public class ProductToAuctionDto : IProductToAuctionDto
|
||||||
public int ProductId { get; set; }
|
public int ProductId { get; set; }
|
||||||
public int AuctionId { get; set; }
|
public int AuctionId { get; set; }
|
||||||
public AuctionStatus AuctionStatus { get; set; }
|
public AuctionStatus AuctionStatus { get; set; }
|
||||||
public int StartingPrice { get; set; }
|
public decimal StartingPrice { get; set; }
|
||||||
public int BidPrice { get; set; }
|
public decimal BidPrice { get; set; }
|
||||||
public int BidAmount { get; set; }
|
public int ProductAmount { get; set; }
|
||||||
|
public int SortIndex { get; set; }
|
||||||
|
|
||||||
public List<AuctionBidDto> AuctionBidDtos { get; } = [];
|
public List<AuctionBidDto> AuctionBidDtos { get; } = [];
|
||||||
|
|
||||||
|
|
@ -29,7 +30,7 @@ public class ProductToAuctionDto : IProductToAuctionDto
|
||||||
AuctionStatus = productToAuction.AuctionStatus;
|
AuctionStatus = productToAuction.AuctionStatus;
|
||||||
StartingPrice = productToAuction.StartingPrice;
|
StartingPrice = productToAuction.StartingPrice;
|
||||||
BidPrice = productToAuction.BidPrice;
|
BidPrice = productToAuction.BidPrice;
|
||||||
BidAmount = productToAuction.BidAmount;
|
ProductAmount = productToAuction.ProductAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductToAuctionMapping CreateMainEntity()
|
public ProductToAuctionMapping CreateMainEntity()
|
||||||
|
|
@ -42,7 +43,7 @@ public class ProductToAuctionDto : IProductToAuctionDto
|
||||||
mainEntity.AuctionStatus = AuctionStatus;
|
mainEntity.AuctionStatus = AuctionStatus;
|
||||||
mainEntity.StartingPrice = StartingPrice;
|
mainEntity.StartingPrice = StartingPrice;
|
||||||
mainEntity.BidPrice = BidPrice;
|
mainEntity.BidPrice = BidPrice;
|
||||||
mainEntity.BidAmount = BidAmount;
|
mainEntity.ProductAmount = ProductAmount;
|
||||||
|
|
||||||
return mainEntity;
|
return mainEntity;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,11 @@ public partial class ProductToAuctionMapping : MgEntityBase, IProductToAuctionMa
|
||||||
[NotColumn]
|
[NotColumn]
|
||||||
public AuctionStatus AuctionStatus { get; set; }
|
public AuctionStatus AuctionStatus { get; set; }
|
||||||
|
|
||||||
public int StartingPrice { get; set; }
|
public decimal StartingPrice { get; set; }
|
||||||
public int BidPrice { get; set; }
|
public decimal BidPrice { get; set; }
|
||||||
|
|
||||||
public int BidAmount { get; set; } = 1;
|
public int ProductAmount { get; set; } = 1;
|
||||||
|
public int SortIndex { get; set; }
|
||||||
|
|
||||||
[SkipValuesOnUpdate]
|
[SkipValuesOnUpdate]
|
||||||
public DateTime Created { get; set; }
|
public DateTime Created { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
using FluentMigrator;
|
||||||
|
using FluentMigrator.Builders.Create.Table;
|
||||||
|
using Nop.Data.Mapping.Builders;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||||
|
using Nop.Data.Extensions;
|
||||||
|
using System.Data;
|
||||||
|
using Nop.Core.Domain.Catalog;
|
||||||
|
using Nop.Core.Domain.Common;
|
||||||
|
using Nop.Data.Mapping;
|
||||||
|
|
||||||
|
namespace Nop.Plugin.Misc.AuctionPlugin.Mapping.Builders;
|
||||||
|
|
||||||
|
public class AuctionBuilder : NopEntityBuilder<Auction>
|
||||||
|
{
|
||||||
|
#region Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Apply entity configuration
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="table">Create table expression builder</param>
|
||||||
|
public override void MapEntity(CreateTableExpressionBuilder table)
|
||||||
|
{
|
||||||
|
table.WithColumn(nameof(Auction.Id)).AsInt32().PrimaryKey().Identity()
|
||||||
|
|
||||||
|
//.WithColumn(nameof(Auction.AuctionId)).AsInt32().ForeignKey<Auction>(onDelete: Rule.Cascade) //Rule.Cascade??
|
||||||
|
//.WithColumn(nameof(Auction.ProductId)).AsInt32().ForeignKey<Product>(onDelete: Rule.Cascade) //Rule.Cascade??
|
||||||
|
|
||||||
|
.WithColumn(nameof(Auction.AuctionType)).AsByte().NotNullable() //enum??? - J.
|
||||||
|
|
||||||
|
//.WithColumn(nameof(Auction.StartingPrice)).AsInt32().NotNullable()
|
||||||
|
//.WithColumn(nameof(Auction.BidPrice)).AsInt32().NotNullable()
|
||||||
|
//.WithColumn(nameof(Auction.BidAmount)).AsInt32().NotNullable().WithDefaultValue(1)
|
||||||
|
.WithColumn(nameof(Auction.Created)).AsDateTime().NotNullable()
|
||||||
|
.WithColumn(nameof(Auction.Modified)).AsDateTime().NotNullable().WithDefault(SystemMethods.CurrentUTCDateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
@ -22,14 +22,16 @@ public class ProductToAuctionMappingBuilder : NopEntityBuilder<ProductToAuctionM
|
||||||
{
|
{
|
||||||
table.WithColumn(nameof(ProductToAuctionMapping.Id)).AsInt32().PrimaryKey().Identity()
|
table.WithColumn(nameof(ProductToAuctionMapping.Id)).AsInt32().PrimaryKey().Identity()
|
||||||
|
|
||||||
.WithColumn(nameof(ProductToAuctionMapping.AuctionId)).AsInt32().ForeignKey<Auction>(onDelete: Rule.None) //Rule.Cascade??
|
.WithColumn(nameof(ProductToAuctionMapping.AuctionId)).AsInt32().ForeignKey<Auction>(onDelete: Rule.Cascade) //Rule.Cascade??
|
||||||
.WithColumn(nameof(ProductToAuctionMapping.ProductId)).AsInt32().ForeignKey<Product>(onDelete: Rule.None) //Rule.Cascade??
|
.WithColumn(nameof(ProductToAuctionMapping.ProductId)).AsInt32().ForeignKey<Product>(onDelete: Rule.Cascade) //Rule.Cascade??
|
||||||
|
|
||||||
//.WithColumn(nameof(ProductToAuctionMapping.AuctionStatus)).AsByte().NotNullable() //enum??? - J.
|
.WithColumn(nameof(ProductToAuctionMapping.AuctionStatus)).AsByte().NotNullable() //enum??? - J.
|
||||||
|
|
||||||
.WithColumn(nameof(ProductToAuctionMapping.StartingPrice)).AsInt32().NotNullable()
|
.WithColumn(nameof(ProductToAuctionMapping.StartingPrice)).AsInt32().NotNullable()
|
||||||
.WithColumn(nameof(ProductToAuctionMapping.BidPrice)).AsInt32().NotNullable()
|
.WithColumn(nameof(ProductToAuctionMapping.BidPrice)).AsInt32().NotNullable()
|
||||||
.WithColumn(nameof(ProductToAuctionMapping.BidAmount)).AsInt32().NotNullable().WithDefaultValue(1)
|
.WithColumn(nameof(ProductToAuctionMapping.ProductAmount)).AsInt32().NotNullable().WithDefaultValue(1)
|
||||||
|
.WithColumn(nameof(ProductToAuctionMapping.SortIndex)).AsInt32().NotNullable().WithDefaultValue(0)
|
||||||
|
|
||||||
.WithColumn(nameof(ProductToAuctionMapping.Created)).AsDateTime().NotNullable()
|
.WithColumn(nameof(ProductToAuctionMapping.Created)).AsDateTime().NotNullable()
|
||||||
.WithColumn(nameof(ProductToAuctionMapping.Modified)).AsDateTime().NotNullable().WithDefault(SystemMethods.CurrentUTCDateTime);
|
.WithColumn(nameof(ProductToAuctionMapping.Modified)).AsDateTime().NotNullable().WithDefault(SystemMethods.CurrentUTCDateTime);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Nop.Core;
|
using AyCode.Core.Extensions;
|
||||||
|
using Nop.Core;
|
||||||
using Nop.Core.Caching;
|
using Nop.Core.Caching;
|
||||||
using Nop.Core.Domain.Customers;
|
using Nop.Core.Domain.Customers;
|
||||||
using Nop.Data;
|
using Nop.Data;
|
||||||
|
|
@ -33,7 +34,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 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;
|
||||||
|
|
@ -50,8 +51,8 @@ public class AuctionService : IAuctionService
|
||||||
/// <param name="staticCacheManager">Cache manager</param>
|
/// <param name="staticCacheManager">Cache manager</param>
|
||||||
public AuctionService(
|
public AuctionService(
|
||||||
AuctionDbContext ctx,
|
AuctionDbContext ctx,
|
||||||
IRepository<Auction> auctionRepository,
|
//IRepository<Auction> auctionRepository,
|
||||||
IRepository<ProductToAuctionMapping> productToAuctionRepository,
|
//IRepository<ProductToAuctionMapping> productToAuctionRepository,
|
||||||
IShortTermCacheManager shortTermCacheManager,
|
IShortTermCacheManager shortTermCacheManager,
|
||||||
IStaticCacheManager staticCacheManager,
|
IStaticCacheManager staticCacheManager,
|
||||||
IWorkContext workContext,
|
IWorkContext workContext,
|
||||||
|
|
@ -60,7 +61,7 @@ public class AuctionService : IAuctionService
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
//_customerBidRepository = customerBidRepository;
|
//_customerBidRepository = customerBidRepository;
|
||||||
//_auctionRepository = auctionRepository;
|
//_auctionRepository = auctionRepository;
|
||||||
_productToAuctionRepository = productToAuctionRepository;
|
//_productToAuctionRepository = productToAuctionRepository;
|
||||||
_shortTermCacheManager = shortTermCacheManager;
|
_shortTermCacheManager = shortTermCacheManager;
|
||||||
_staticCacheManager = staticCacheManager;
|
_staticCacheManager = staticCacheManager;
|
||||||
_workContext = workContext;
|
_workContext = workContext;
|
||||||
|
|
@ -158,7 +159,7 @@ public class AuctionService : IAuctionService
|
||||||
#endregion
|
#endregion
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Dtos
|
#region Dtots
|
||||||
public async Task<AuctionDto> GetAuctionDtoByIdAsync(int auctionId)
|
public async Task<AuctionDto> GetAuctionDtoByIdAsync(int auctionId)
|
||||||
{
|
{
|
||||||
return new AuctionDto(await _ctx.Auctions.GetByIdAsync(auctionId));
|
return new AuctionDto(await _ctx.Auctions.GetByIdAsync(auctionId));
|
||||||
|
|
@ -181,6 +182,7 @@ 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, decimal startingPrice, decimal bidPrice, int auctionId)
|
public async Task<bool> AssignProductToAuctionAsync(int productId, decimal startingPrice, decimal bidPrice, int auctionId)
|
||||||
{
|
{
|
||||||
var auction = await _ctx.Auctions.GetByIdAsync(auctionId);
|
var auction = await _ctx.Auctions.GetByIdAsync(auctionId);
|
||||||
|
|
@ -190,9 +192,9 @@ public class AuctionService : IAuctionService
|
||||||
var mapping = new ProductToAuctionMapping
|
var mapping = new ProductToAuctionMapping
|
||||||
{
|
{
|
||||||
ProductId = productId,
|
ProductId = productId,
|
||||||
StartingPrice = Convert.ToInt32(startingPrice),
|
StartingPrice = startingPrice,
|
||||||
BidPrice = Convert.ToInt32(bidPrice),
|
BidPrice = bidPrice,
|
||||||
BidAmount = 0,
|
ProductAmount = 0,
|
||||||
AuctionStatus = Domains.Enums.AuctionStatus.Active,
|
AuctionStatus = Domains.Enums.AuctionStatus.Active,
|
||||||
AuctionId = auctionId
|
AuctionId = auctionId
|
||||||
};
|
};
|
||||||
|
|
@ -200,9 +202,11 @@ public class AuctionService : IAuctionService
|
||||||
{
|
{
|
||||||
await _ctx.ProductToAuctions.InsertAsync(mapping);
|
await _ctx.ProductToAuctions.InsertAsync(mapping);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex)
|
||||||
|
{
|
||||||
await _logger.InformationAsync(ex.ToString());
|
await _logger.InformationAsync(ex.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<button id="testButton" class="btn btn-success" style="display: none">
|
<button id="testButton" class="btn btn-success">
|
||||||
TestButton
|
TestButton
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue