improvements, fixes, etc...
This commit is contained in:
parent
840dae2969
commit
d9f95dd8e1
|
|
@ -1,5 +1,6 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Nop.Core;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Models;
|
||||
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||
|
|
@ -76,29 +77,35 @@ public class AuctionViewComponent : NopViewComponent
|
|||
//{
|
||||
// return Content(string.Empty);
|
||||
//}
|
||||
var model = new AuctionPublicInfoModel();
|
||||
|
||||
|
||||
if (!widgetZone.Equals(PublicWidgetZones.ProductBoxAddinfoBefore))
|
||||
{
|
||||
return Content(string.Empty);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
var auctionDto = (await _auctionService.GetAuctionDtoByIdAsync(productToAuctionDtoMappings.FirstOrDefault()!.AuctionId));
|
||||
auctionDto.ProductToAuctionDtos.AddRange(productToAuctionDtoMappings);
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ public interface IProductToAuctionDtoBase : IMgModelDtoBase
|
|||
public int ProductId { get; set; }
|
||||
public int AuctionId { get; set; }
|
||||
|
||||
public int WinnerCustomerId { get; set; }
|
||||
public AuctionStatus AuctionStatus { get; set; }
|
||||
|
||||
public decimal StartingPrice { get; set; }
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ public class ProductToAuctionDto : IProductToAuctionDto
|
|||
public int Id { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public int AuctionId { get; set; }
|
||||
public int WinnerCustomerId { get; set; }
|
||||
public AuctionStatus AuctionStatus { get; set; }
|
||||
public decimal StartingPrice { get; set; }
|
||||
public decimal BidPrice { get; set; }
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ public partial class ProductToAuctionMapping : MgEntityBase, IProductToAuctionMa
|
|||
{
|
||||
public int ProductId { get; set; }
|
||||
public int AuctionId { get; set; }
|
||||
public int WinnerCustomerId { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
[NotColumn]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
// NotSold = 25
|
||||
//}
|
||||
|
||||
[Flags]
|
||||
//[Flags]
|
||||
public enum AuctionStatus : byte
|
||||
{
|
||||
None = 0,
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Hubs
|
|||
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)
|
||||
{
|
||||
_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(),
|
||||
BidPrice = auctionBid.BidPrice.ToString(CultureInfo.InvariantCulture),
|
||||
NextStepAmount = "50000", //TODO: - J.
|
||||
|
||||
ToasterMessage = string.Empty, //TODO: - J.
|
||||
}.ToJson()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,18 +1,40 @@
|
|||
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;
|
||||
|
||||
namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||
{
|
||||
public record AuctionPublicInfoModel : BaseNopModel
|
||||
{
|
||||
[JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public AuctionDto AuctionDto { get; set; }
|
||||
|
||||
public int ProductId { get; set; }
|
||||
[JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public ProductToAuctionDto FirstProductToAuction { get; set; }
|
||||
|
||||
public int ProductToAuctionMappingId { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
|
||||
public int ProductToAuctionMappingId { get; set; }
|
||||
|
||||
public DateTime StartDate { 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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
var auctionBid = await _ctx.AuctionBids.GetByIdAsync(auctionBidId);
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ public class EventConsumer :
|
|||
|
||||
public async Task HandleEventAsync(EntityUpdatedEvent<Product> eventMessage)
|
||||
{
|
||||
//eventMessage.
|
||||
//send notification on SignalR
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
function refreshPublicInfo@(Model.ProductId)(data) {
|
||||
|
||||
console.log('function called: refreshPublicInfo'+@(Model.ProductId))
|
||||
console.log('function called: refreshPublicInfo' + @(Model.ProductId));
|
||||
}
|
||||
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue