improvements, fixes, etc...
This commit is contained in:
parent
840dae2969
commit
d9f95dd8e1
|
|
@ -1,5 +1,6 @@
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Nop.Core;
|
using Nop.Core;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Models;
|
using Nop.Plugin.Misc.AuctionPlugin.Models;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
|
|
@ -76,7 +77,6 @@ public class AuctionViewComponent : NopViewComponent
|
||||||
//{
|
//{
|
||||||
// return Content(string.Empty);
|
// return Content(string.Empty);
|
||||||
//}
|
//}
|
||||||
var model = new AuctionPublicInfoModel();
|
|
||||||
|
|
||||||
if (!widgetZone.Equals(PublicWidgetZones.ProductBoxAddinfoBefore))
|
if (!widgetZone.Equals(PublicWidgetZones.ProductBoxAddinfoBefore))
|
||||||
{
|
{
|
||||||
|
|
@ -84,21 +84,28 @@ public class AuctionViewComponent : NopViewComponent
|
||||||
}
|
}
|
||||||
|
|
||||||
var productId = ((ProductOverviewModel)additionalData).Id;
|
var productId = ((ProductOverviewModel)additionalData).Id;
|
||||||
model.ProductId = productId;
|
|
||||||
var productToAuctionMapping = (await _auctionService.GetProductToAuctionsByProductIdAsync(productId)).FirstOrDefault();
|
|
||||||
|
|
||||||
if (productToAuctionMapping == null)
|
|
||||||
|
//model.ProductId = productId;
|
||||||
|
|
||||||
|
var productToAuctionDtoMappings = await _auctionService.GetProductToAuctionDtosByProductIdAsync(productId);
|
||||||
|
if (productToAuctionDtoMappings.Count == 0)
|
||||||
{
|
{
|
||||||
return Content(string.Empty);
|
return Content(string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
model.ProductToAuctionMappingId = productToAuctionMapping.Id;
|
var auctionDto = (await _auctionService.GetAuctionDtoByIdAsync(productToAuctionDtoMappings.FirstOrDefault()!.AuctionId));
|
||||||
var auction = await _auctionService.GetAuctionDtoByProductToAuctionIdAsync(productToAuctionMapping.Id);
|
auctionDto.ProductToAuctionDtos.AddRange(productToAuctionDtoMappings);
|
||||||
model.StartDate = auction.StartDateUtc;
|
|
||||||
AuctionStatus status = productToAuctionMapping.AuctionStatus;
|
|
||||||
model.IsActive = status.HasFlag(AuctionStatus.Active);
|
|
||||||
|
|
||||||
bool isFirstWarning = status.HasFlag(AuctionStatus.FirstWarning);
|
var model = new AuctionPublicInfoModel(auctionDto);
|
||||||
|
|
||||||
|
//model.ProductToAuctionMappingId = productToAuctionMapping.Id;
|
||||||
|
//var auction = await _auctionService.GetAuctionDtoByProductToAuctionIdAsync(productToAuctionMapping.Id);
|
||||||
|
//model.StartDate = auction.StartDateUtc;
|
||||||
|
//AuctionStatus status = productToAuctionMapping.AuctionStatus;
|
||||||
|
//model.IsActive = status.HasFlag(AuctionStatus.Active);
|
||||||
|
|
||||||
|
//bool isFirstWarning = status.HasFlag(AuctionStatus.FirstWarning);
|
||||||
|
|
||||||
return View("~/Plugins/Misc.AuctionPlugin/Views/PublicInfo.cshtml", model);
|
return View("~/Plugins/Misc.AuctionPlugin/Views/PublicInfo.cshtml", model);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ public interface IProductToAuctionDtoBase : IMgModelDtoBase
|
||||||
public int ProductId { get; set; }
|
public int ProductId { get; set; }
|
||||||
public int AuctionId { get; set; }
|
public int AuctionId { get; set; }
|
||||||
|
|
||||||
|
public int WinnerCustomerId { get; set; }
|
||||||
public AuctionStatus AuctionStatus { get; set; }
|
public AuctionStatus AuctionStatus { get; set; }
|
||||||
|
|
||||||
public decimal StartingPrice { get; set; }
|
public decimal StartingPrice { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ public class ProductToAuctionDto : IProductToAuctionDto
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int ProductId { get; set; }
|
public int ProductId { get; set; }
|
||||||
public int AuctionId { get; set; }
|
public int AuctionId { get; set; }
|
||||||
|
public int WinnerCustomerId { get; set; }
|
||||||
public AuctionStatus AuctionStatus { get; set; }
|
public AuctionStatus AuctionStatus { get; set; }
|
||||||
public decimal StartingPrice { get; set; }
|
public decimal StartingPrice { get; set; }
|
||||||
public decimal BidPrice { get; set; }
|
public decimal BidPrice { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ public partial class ProductToAuctionMapping : MgEntityBase, IProductToAuctionMa
|
||||||
{
|
{
|
||||||
public int ProductId { get; set; }
|
public int ProductId { get; set; }
|
||||||
public int AuctionId { get; set; }
|
public int AuctionId { get; set; }
|
||||||
|
public int WinnerCustomerId { get; set; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
[NotColumn]
|
[NotColumn]
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
// NotSold = 25
|
// NotSold = 25
|
||||||
//}
|
//}
|
||||||
|
|
||||||
[Flags]
|
//[Flags]
|
||||||
public enum AuctionStatus : byte
|
public enum AuctionStatus : byte
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,6 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: A MessageWrapper-ben kéne küldözgetni a UserId (CustomerId-t) - J.
|
|
||||||
if (message.SenderId <= 0 || message.SenderId != (await _workContext.GetCurrentCustomerAsync()).Id)
|
if (message.SenderId <= 0 || message.SenderId != (await _workContext.GetCurrentCustomerAsync()).Id)
|
||||||
{
|
{
|
||||||
_logger.Error($"SignalRMessageHandler.HandleMessage(); message.SenderId <= 0 || message.SenderId != (await _workContext.GetCurrentCustomerAsync()).Id");
|
_logger.Error($"SignalRMessageHandler.HandleMessage(); message.SenderId <= 0 || message.SenderId != (await _workContext.GetCurrentCustomerAsync()).Id");
|
||||||
|
|
@ -214,6 +213,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
||||||
ProductName = auctionBid.ProductId.ToString(),
|
ProductName = auctionBid.ProductId.ToString(),
|
||||||
BidPrice = auctionBid.BidPrice.ToString(CultureInfo.InvariantCulture),
|
BidPrice = auctionBid.BidPrice.ToString(CultureInfo.InvariantCulture),
|
||||||
NextStepAmount = "50000", //TODO: - J.
|
NextStepAmount = "50000", //TODO: - J.
|
||||||
|
|
||||||
ToasterMessage = string.Empty, //TODO: - J.
|
ToasterMessage = string.Empty, //TODO: - J.
|
||||||
}.ToJson()
|
}.ToJson()
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,19 @@
|
||||||
using Nop.Web.Framework.Models;
|
using Newtonsoft.Json;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||||
|
using Nop.Web.Framework.Models;
|
||||||
using Nop.Web.Framework.Mvc.ModelBinding;
|
using Nop.Web.Framework.Mvc.ModelBinding;
|
||||||
|
|
||||||
namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
{
|
{
|
||||||
public record AuctionPublicInfoModel : BaseNopModel
|
public record AuctionPublicInfoModel : BaseNopModel
|
||||||
{
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
[System.Text.Json.Serialization.JsonIgnore]
|
||||||
|
public AuctionDto AuctionDto { get; set; }
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
[System.Text.Json.Serialization.JsonIgnore]
|
||||||
|
public ProductToAuctionDto FirstProductToAuction { get; set; }
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
public int ProductId { get; set; }
|
||||||
|
|
||||||
|
|
@ -14,5 +23,18 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
|
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public AuctionPublicInfoModel() {}
|
||||||
|
|
||||||
|
public AuctionPublicInfoModel(AuctionDto auctionDto) : this()
|
||||||
|
{
|
||||||
|
AuctionDto = auctionDto;
|
||||||
|
FirstProductToAuction = AuctionDto.ProductToAuctionDtos.First();
|
||||||
|
|
||||||
|
ProductId = FirstProductToAuction.ProductId;
|
||||||
|
ProductToAuctionMappingId = FirstProductToAuction.Id;
|
||||||
|
StartDate = AuctionDto.StartDateUtc;
|
||||||
|
IsActive = FirstProductToAuction.IsActiveItem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,11 @@ public class AuctionService : IAuctionService
|
||||||
return auctionDto;
|
return auctionDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<ProductToAuctionDto>> GetProductToAuctionDtosByProductIdAsync(int productId)
|
||||||
|
{
|
||||||
|
return [..await _ctx.ProductToAuctions.GetByProductId(productId).Select(x=>new ProductToAuctionDto(x)).ToListAsync()];
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<AuctionBidDto> GetAuctionBidDtoByIdAsync(int auctionBidId)
|
public async Task<AuctionBidDto> GetAuctionBidDtoByIdAsync(int auctionBidId)
|
||||||
{
|
{
|
||||||
var auctionBid = await _ctx.AuctionBids.GetByIdAsync(auctionBidId);
|
var auctionBid = await _ctx.AuctionBids.GetByIdAsync(auctionBidId);
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,7 @@ public class EventConsumer :
|
||||||
|
|
||||||
public async Task HandleEventAsync(EntityUpdatedEvent<Product> eventMessage)
|
public async Task HandleEventAsync(EntityUpdatedEvent<Product> eventMessage)
|
||||||
{
|
{
|
||||||
|
//eventMessage.
|
||||||
//send notification on SignalR
|
//send notification on SignalR
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
|
|
||||||
function refreshPublicInfo@(Model.ProductId)(data) {
|
function refreshPublicInfo@(Model.ProductId)(data) {
|
||||||
|
|
||||||
console.log('function called: refreshPublicInfo'+@(Model.ProductId))
|
console.log('function called: refreshPublicInfo' + @(Model.ProductId));
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue