Livescreen updates
This commit is contained in:
parent
df49860936
commit
0e08842f95
|
|
@ -66,7 +66,7 @@ public class AuctionPublicViewComponent : NopViewComponent
|
|||
/// </returns>
|
||||
public async Task<IViewComponentResult> InvokeAsync(string widgetZone, object additionalData)
|
||||
{
|
||||
ProductBidBoxViewModel productBidBoxViewModel = new ProductBidBoxViewModel();
|
||||
|
||||
|
||||
await _logger.InformationAsync("WidgetViewComponent called");
|
||||
|
||||
|
|
@ -103,54 +103,35 @@ public class AuctionPublicViewComponent : NopViewComponent
|
|||
|
||||
//is it under Auction?
|
||||
|
||||
List<ProductToAuctionMapping> auctionIds = await _auctionService.GetProductToAuctionsByProductIdAsync(productDetailsModel.Id);
|
||||
int auctionId = 0;
|
||||
AuctionDto auction;
|
||||
if(auctionIds == null || auctionIds.Count == 0)
|
||||
var productId = productDetailsModel.Id;
|
||||
|
||||
var productToAuctionDtoMappings = await _auctionService.GetProductToAuctionDtosByProductIdAsync(productId);
|
||||
if (productToAuctionDtoMappings.Count == 0)
|
||||
{
|
||||
return Content(string.Empty);
|
||||
}
|
||||
|
||||
if (auctionIds.Count > 1)
|
||||
{
|
||||
List<AuctionDto> openAuctionList = [];
|
||||
var auctionDto = (await _auctionService.GetAuctionDtoByIdAsync(productToAuctionDtoMappings.FirstOrDefault()!.AuctionId));
|
||||
auctionDto.ProductToAuctionDtos.AddRange(productToAuctionDtoMappings);
|
||||
|
||||
//we have more auctions so we return the closest open
|
||||
foreach (var auctionMapping in auctionIds)
|
||||
{
|
||||
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;
|
||||
var productBidBoxViewModel = new ProductBidBoxViewModel(auctionDto);
|
||||
//List<ProductToAuctionMapping> productToAuctionId = await _auctionService.GetProductToAuctionByAuctionIdAndProductIdAsync(auctionId, productDetailsModel.Id);
|
||||
|
||||
}
|
||||
|
||||
List<ProductToAuctionMapping> productToAuctionId = await _auctionService.GetProductToAuctionByAuctionIdAndProductIdAsync(auctionId, productDetailsModel.Id);
|
||||
|
||||
AuctionStatus status = productToAuctionId.FirstOrDefault().AuctionStatus;
|
||||
AuctionStatus status = productToAuctionDtoMappings.FirstOrDefault()!.AuctionStatus;
|
||||
bool isActive = status.HasFlag(AuctionStatus.Active);
|
||||
bool isFirstWarning = status.HasFlag(AuctionStatus.FirstWarning);
|
||||
|
||||
|
||||
productBidBoxViewModel.IsAdmin = await _customerService.IsAdminAsync(customer);
|
||||
productBidBoxViewModel.IsGuest = await _customerService.IsGuestAsync(customer);
|
||||
productBidBoxViewModel.AuctionClosed = auction.Closed;
|
||||
productBidBoxViewModel.IsItemActive = isActive;
|
||||
//productBidBoxViewModel.AuctionClosed = auction.Closed;
|
||||
|
||||
//productBidBoxViewModel.IsItemActive = isActive;
|
||||
productBidBoxViewModel.WidgetZone = widgetZone;
|
||||
productBidBoxViewModel.BasePrice = productDetailsModel.ProductPrice.OldPriceValue;
|
||||
productBidBoxViewModel.CurrentPrice = productDetailsModel.ProductPrice.PriceValue;
|
||||
productBidBoxViewModel.ProductToAuctionId = productToAuctionId.FirstOrDefault().Id;
|
||||
productBidBoxViewModel.AuctionId = auctionId;
|
||||
//productBidBoxViewModel.ProductToAuctionId = productToAuctionId.FirstOrDefault().Id;
|
||||
//productBidBoxViewModel.AuctionId = auctionId;
|
||||
productBidBoxViewModel.CustomerId = customer.Id;
|
||||
productBidBoxViewModel.ProductId = productDetailsModel.Id;
|
||||
productBidBoxViewModel.LicitStep = 50000; //add calculation
|
||||
|
|
|
|||
|
|
@ -71,9 +71,24 @@ public class AuctionController : BasePluginController
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Infrastructure
|
|||
defaults: new { controller = "AuctionPluginAdmin", action = "AssignProductToAuction" });
|
||||
|
||||
endpointRouteBuilder.MapControllerRoute(name: AuctionDefaults.LiveScreenRouteName,
|
||||
pattern: "Auction/LiveScreen",
|
||||
pattern: "Auction/LiveScreen/{auctionId}",
|
||||
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.Mvc.ModelBinding;
|
||||
using Nop.Web.Models.Catalog;
|
||||
|
|
@ -8,16 +9,55 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
|||
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; }
|
||||
|
||||
public bool IsActive { get; set; }
|
||||
|
||||
public AuctionDto CurrentAuction { get; set; }
|
||||
[JsonIgnore]
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public ProductToAuctionDto FirstProductToAuction { 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 System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -10,16 +12,25 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
|||
{
|
||||
public record ProductBidBoxViewModel: BaseNopModel
|
||||
{
|
||||
public int ProductToAuctionId { get; set; }
|
||||
public bool IsAdmin { get; set; }
|
||||
public bool IsGuest { get; set; }
|
||||
public int AuctionId { get; set; }
|
||||
public bool AuctionClosed { get; set; }
|
||||
public bool IsItemActive { get; set; }
|
||||
[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 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; }
|
||||
public string WidgetZone { get; set; }
|
||||
|
||||
|
||||
#region debug fields to be removed
|
||||
|
|
@ -35,5 +46,19 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
|||
|
||||
#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,11 +9,91 @@
|
|||
//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>
|
||||
|
||||
|
||||
<!-- 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>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue