merge
This commit is contained in:
commit
5b15c2d52d
|
|
@ -66,7 +66,7 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
||||||
{
|
{
|
||||||
ProductBidBoxViewModel productBidBoxViewModel = new ProductBidBoxViewModel();
|
|
||||||
|
|
||||||
await _logger.InformationAsync("WidgetViewComponent called");
|
await _logger.InformationAsync("WidgetViewComponent called");
|
||||||
|
|
||||||
|
|
@ -103,39 +103,19 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
|
|
||||||
//is it under Auction?
|
//is it under Auction?
|
||||||
|
|
||||||
List<ProductToAuctionMapping> auctionIds = await _auctionService.GetProductToAuctionsByProductIdAsync(productDetailsModel.Id);
|
var productId = productDetailsModel.Id;
|
||||||
int auctionId = 0;
|
|
||||||
AuctionDto auction;
|
var productToAuctionDtoMappings = await _auctionService.GetProductToAuctionDtosByProductIdAsync(productId);
|
||||||
if(auctionIds == null || auctionIds.Count == 0)
|
if (productToAuctionDtoMappings.Count == 0)
|
||||||
{
|
{
|
||||||
return Content(string.Empty);
|
return Content(string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auctionIds.Count > 1)
|
var auctionDto = (await _auctionService.GetAuctionDtoByIdAsync(productToAuctionDtoMappings.FirstOrDefault()!.AuctionId));
|
||||||
{
|
auctionDto.ProductToAuctionDtos.AddRange(productToAuctionDtoMappings);
|
||||||
List<AuctionDto> openAuctionList = [];
|
|
||||||
|
|
||||||
//we have more auctions so we return the closest open
|
var productBidBoxViewModel = new ProductBidBoxViewModel(auctionDto);
|
||||||
foreach (var auctionMapping in auctionIds)
|
//List<ProductToAuctionMapping> productToAuctionId = await _auctionService.GetProductToAuctionByAuctionIdAndProductIdAsync(auctionId, productDetailsModel.Id);
|
||||||
{
|
|
||||||
var auctionItem = await _auctionService.GetAuctionDtoByIdAsync(auctionMapping.AuctionId);
|
|
||||||
if (!auctionItem.Closed)
|
|
||||||
{
|
|
||||||
openAuctionList.Add(auctionItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//first auction that started or strats not earlier than yesterday
|
|
||||||
auction = openAuctionList.Where(x => x.StartDateUtc > DateTime.UtcNow.AddDays(-1)).OrderBy(x => x.StartDateUtc).FirstOrDefault();
|
|
||||||
auctionId = auction.Id;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auction = await _auctionService.GetAuctionDtoByIdAsync(auctionIds.FirstOrDefault().AuctionId);
|
|
||||||
auctionId = auction.Id;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ProductToAuctionMapping> productToAuctionId = await _auctionService.GetProductToAuctionByAuctionIdAndProductIdAsync(auctionId, productDetailsModel.Id);
|
|
||||||
|
|
||||||
AuctionStatus status = productToAuctionId.FirstOrDefault().AuctionStatus;
|
AuctionStatus status = productToAuctionId.FirstOrDefault().AuctionStatus;
|
||||||
//bool isActive = status == AuctionStatus.Active || status == AuctionStatus.FirstWarning || status == AuctionStatus.SecondWarning;
|
//bool isActive = status == AuctionStatus.Active || status == AuctionStatus.FirstWarning || status == AuctionStatus.SecondWarning;
|
||||||
|
|
@ -150,8 +130,8 @@ public class AuctionPublicViewComponent : NopViewComponent
|
||||||
productBidBoxViewModel.WidgetZone = widgetZone;
|
productBidBoxViewModel.WidgetZone = widgetZone;
|
||||||
productBidBoxViewModel.BasePrice = productDetailsModel.ProductPrice.OldPriceValue;
|
productBidBoxViewModel.BasePrice = productDetailsModel.ProductPrice.OldPriceValue;
|
||||||
productBidBoxViewModel.CurrentPrice = productDetailsModel.ProductPrice.PriceValue;
|
productBidBoxViewModel.CurrentPrice = productDetailsModel.ProductPrice.PriceValue;
|
||||||
productBidBoxViewModel.ProductToAuctionId = productToAuctionId.FirstOrDefault().Id;
|
//productBidBoxViewModel.ProductToAuctionId = productToAuctionId.FirstOrDefault().Id;
|
||||||
productBidBoxViewModel.AuctionId = auctionId;
|
//productBidBoxViewModel.AuctionId = auctionId;
|
||||||
productBidBoxViewModel.CustomerId = customer.Id;
|
productBidBoxViewModel.CustomerId = customer.Id;
|
||||||
productBidBoxViewModel.ProductId = productDetailsModel.Id;
|
productBidBoxViewModel.ProductId = productDetailsModel.Id;
|
||||||
productBidBoxViewModel.LicitStep = 50000; //add calculation
|
productBidBoxViewModel.LicitStep = 50000; //add calculation
|
||||||
|
|
|
||||||
|
|
@ -71,9 +71,24 @@ public class AuctionController : BasePluginController
|
||||||
return ViewComponent("AuctionPublic", new { widgetZone = request.WidgetZone, additionalData = detailsModel });
|
return ViewComponent("AuctionPublic", new { widgetZone = request.WidgetZone, additionalData = detailsModel });
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IActionResult> LiveScreen()
|
public async Task<IActionResult> LiveScreen(int auctionId)
|
||||||
{
|
{
|
||||||
var model = new LiveScreenViewModel();
|
|
||||||
|
var auctionDto = await _auctionService.GetAuctionDtoByIdAsync(auctionId);
|
||||||
|
|
||||||
|
var productToAuctionDtoMappings = await _auctionService.GetProductToAuctionsByAuctionIdAsync(auctionId, false);
|
||||||
|
|
||||||
|
//auctionDto.ProductToAuctionDtos.AddRange(productToAuctionDtoMappings);
|
||||||
|
|
||||||
|
var model = new LiveScreenViewModel(auctionDto);
|
||||||
|
|
||||||
|
var product = await _productService.GetProductByIdAsync(auctionDto.ProductToAuctionDtos.FirstOrDefault().Id);
|
||||||
|
|
||||||
|
var productDetailsModel = await _productModelFactory.PrepareProductDetailsModelAsync(product);
|
||||||
|
|
||||||
|
|
||||||
|
model.ProductDetails = productDetailsModel;
|
||||||
|
|
||||||
return View("~/Plugins/Misc.AuctionPlugin/Views/LiveScreen.cshtml", model);
|
return View("~/Plugins/Misc.AuctionPlugin/Views/LiveScreen.cshtml", model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,7 +55,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
|
||||||
defaults: new { controller = "AuctionPluginAdmin", action = "AssignProductToAuction" });
|
defaults: new { controller = "AuctionPluginAdmin", action = "AssignProductToAuction" });
|
||||||
|
|
||||||
endpointRouteBuilder.MapControllerRoute(name: AuctionDefaults.LiveScreenRouteName,
|
endpointRouteBuilder.MapControllerRoute(name: AuctionDefaults.LiveScreenRouteName,
|
||||||
pattern: "Auction/LiveScreen",
|
pattern: "Auction/LiveScreen/{auctionId}",
|
||||||
defaults: new { controller = "Auction", action = "LiveScreen" });
|
defaults: new { controller = "Auction", action = "LiveScreen" });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
using Newtonsoft.Json;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||||
using Nop.Web.Framework.Models;
|
using Nop.Web.Framework.Models;
|
||||||
using Nop.Web.Framework.Mvc.ModelBinding;
|
using Nop.Web.Framework.Mvc.ModelBinding;
|
||||||
using Nop.Web.Models.Catalog;
|
using Nop.Web.Models.Catalog;
|
||||||
|
|
@ -8,16 +9,55 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
public record LiveScreenViewModel : BaseNopModel
|
public record LiveScreenViewModel : BaseNopModel
|
||||||
{
|
{
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
[JsonIgnore]
|
||||||
|
[System.Text.Json.Serialization.JsonIgnore]
|
||||||
|
public AuctionDto AuctionDto { get; set; }
|
||||||
|
|
||||||
public DateTime StartDate { get; set; }
|
[JsonIgnore]
|
||||||
|
[System.Text.Json.Serialization.JsonIgnore]
|
||||||
public bool IsActive { get; set; }
|
public ProductToAuctionDto FirstProductToAuction { get; set; }
|
||||||
|
|
||||||
public AuctionDto CurrentAuction { get; set; }
|
|
||||||
|
|
||||||
public ProductDetailsModel ProductDetails { get; set; }
|
public ProductDetailsModel ProductDetails { get; set; }
|
||||||
|
|
||||||
|
public int ProductId { get; set; }
|
||||||
|
|
||||||
|
public int ProductToAuctionId { get; set; }
|
||||||
|
public bool IsAdmin { get; set; }
|
||||||
|
public bool IsGuest { get; set; }
|
||||||
|
|
||||||
|
public int AuctionId { get; set; }
|
||||||
|
public bool IsItemActive { get; set; }
|
||||||
|
public int CustomerId { get; set; }
|
||||||
|
|
||||||
|
public string WidgetZone { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
#region debug fields to be removed
|
||||||
|
|
||||||
|
public decimal? BasePrice { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region visible
|
||||||
|
public decimal LicitStep { get; set; }
|
||||||
|
public decimal? CurrentPrice { get; set; }
|
||||||
|
public decimal BidPrice { get; set; }
|
||||||
|
|
||||||
|
#endregion visible
|
||||||
|
|
||||||
|
public LiveScreenViewModel() { }
|
||||||
|
|
||||||
|
public LiveScreenViewModel(AuctionDto auctionDto) : this()
|
||||||
|
{
|
||||||
|
AuctionDto = auctionDto;
|
||||||
|
FirstProductToAuction = AuctionDto.ProductToAuctionDtos.First();
|
||||||
|
|
||||||
|
AuctionId = auctionDto.Id;
|
||||||
|
ProductId = FirstProductToAuction.ProductId;
|
||||||
|
ProductToAuctionId = FirstProductToAuction.Id;
|
||||||
|
IsItemActive = FirstProductToAuction.IsActiveItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
using Newtonsoft.Json;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
|
||||||
using Nop.Web.Framework.Models;
|
using Nop.Web.Framework.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
@ -10,9 +12,20 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
{
|
{
|
||||||
public record ProductBidBoxViewModel: BaseNopModel
|
public record ProductBidBoxViewModel: 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 ProductToAuctionId { get; set; }
|
public int ProductToAuctionId { get; set; }
|
||||||
public bool IsAdmin { get; set; }
|
public bool IsAdmin { get; set; }
|
||||||
public bool IsGuest { get; set; }
|
public bool IsGuest { get; set; }
|
||||||
|
|
||||||
public int AuctionId { get; set; }
|
public int AuctionId { get; set; }
|
||||||
public bool AuctionClosed { get; set; }
|
public bool AuctionClosed { get; set; }
|
||||||
public bool IsItemActive => AuctionStatus is AuctionStatus.Active or AuctionStatus.FirstWarning or AuctionStatus.SecondWarning;
|
public bool IsItemActive => AuctionStatus is AuctionStatus.Active or AuctionStatus.FirstWarning or AuctionStatus.SecondWarning;
|
||||||
|
|
@ -36,5 +49,19 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
|
|
||||||
#endregion visible
|
#endregion visible
|
||||||
|
|
||||||
|
public ProductBidBoxViewModel() { }
|
||||||
|
|
||||||
|
public ProductBidBoxViewModel(AuctionDto auctionDto) : this()
|
||||||
|
{
|
||||||
|
AuctionDto = auctionDto;
|
||||||
|
FirstProductToAuction = AuctionDto.ProductToAuctionDtos.First();
|
||||||
|
|
||||||
|
AuctionId = auctionDto.Id;
|
||||||
|
ProductId = FirstProductToAuction.ProductId;
|
||||||
|
ProductToAuctionId = FirstProductToAuction.Id;
|
||||||
|
IsItemActive = FirstProductToAuction.IsActiveItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,93 @@
|
||||||
//page title
|
//page title
|
||||||
|
|
||||||
}
|
}
|
||||||
<div>
|
|
||||||
|
|
||||||
<h1>Live screen</h1>
|
<div class="row">
|
||||||
|
<!-- Item Image -->
|
||||||
|
<div class="col-lg-5 col-md-6 mb-4">
|
||||||
|
<div class="card shadow-sm">
|
||||||
|
<img src="@Model.ProductDetails.DefaultPictureModel.FullSizeImageUrl" class="card-img-top img-fluid" alt="Auction Item Image">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Item Details -->
|
||||||
|
<div class="col-lg-7 col-md-6">
|
||||||
|
<div class="card shadow-sm">
|
||||||
|
<div class="card-body">
|
||||||
|
<h3 class="card-title">Auction Item Title</h3>
|
||||||
|
<p class="text-muted mb-3">Created by: <span class="font-weight-bold">Creator Name</span></p>
|
||||||
|
|
||||||
|
<!-- Item Information -->
|
||||||
|
<ul class="list-group mb-3">
|
||||||
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||||
|
<span>Size</span>
|
||||||
|
<span>10 x 12 inches</span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||||
|
<span>Material</span>
|
||||||
|
<span>Oil on Canvas</span>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<span class="font-weight-bold">Description:</span>
|
||||||
|
<p class="mb-0 mt-2 text-muted">
|
||||||
|
A beautiful depiction of a serene landscape, perfect for any art lover or collector.
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mt-4">
|
||||||
|
<!-- Bid History Table -->
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card shadow-sm">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title mb-3">Bid History</h5>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="bidHistoryTable" class="table table-striped table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>#</th>
|
||||||
|
<th>Bidder</th>
|
||||||
|
<th>Bid Amount</th>
|
||||||
|
<th>Date</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<!-- Dynamic Data Populated by DataTable -->
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Initialize DataTable -->
|
||||||
|
<script>
|
||||||
|
$(document).ready(function () {
|
||||||
|
$('#bidHistoryTable').DataTable({
|
||||||
|
"pageLength": 10,
|
||||||
|
"ordering": true,
|
||||||
|
"searching": true,
|
||||||
|
"info": true,
|
||||||
|
"lengthChange": false,
|
||||||
|
"columns": [
|
||||||
|
{ "data": "#" },
|
||||||
|
{ "data": "Bidder" },
|
||||||
|
{ "data": "Bid Amount" },
|
||||||
|
{ "data": "Date" }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue