ghdkjg fdskhgk
This commit is contained in:
parent
69a6cd5053
commit
ef98268f03
|
|
@ -1,8 +1,11 @@
|
||||||
using AyCode.Core.Extensions;
|
using AyCode.Core.Extensions;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Nop.Core.Domain.Catalog;
|
||||||
using Nop.Data;
|
using Nop.Data;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models;
|
using Nop.Plugin.Misc.AuctionPlugin.Areas.Admin.Models;
|
||||||
|
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
|
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.Models;
|
||||||
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
||||||
using Nop.Services.Catalog;
|
using Nop.Services.Catalog;
|
||||||
|
|
@ -74,20 +77,64 @@ public class AuctionController : BasePluginController
|
||||||
public async Task<IActionResult> LiveScreen(int auctionId)
|
public async Task<IActionResult> LiveScreen(int auctionId)
|
||||||
{
|
{
|
||||||
|
|
||||||
var auctionDto = await _auctionService.GetAuctionDtoByIdAsync(auctionId);
|
var auctionDto = await _auctionService.GetAuctionDtoByIdAsync(auctionId, true);
|
||||||
|
|
||||||
|
//var auctionDto = _auctionService.GetAuctionDtoWithAuctionBids(int auctionId, bool activeProductOnly)
|
||||||
|
|
||||||
var productToAuctionDtoMappings = await _auctionService.GetProductToAuctionsByAuctionIdAsync(auctionId, false);
|
|
||||||
|
|
||||||
//auctionDto.ProductToAuctionDtos.AddRange(productToAuctionDtoMappings);
|
//auctionDto.ProductToAuctionDtos.AddRange(productToAuctionDtoMappings);
|
||||||
|
|
||||||
|
bool isAnyItemLive = auctionDto.ProductToAuctionDtos.Any(x => x.AuctionStatus == AuctionStatus.Active);
|
||||||
|
|
||||||
var model = new LiveScreenViewModel(auctionDto);
|
var model = new LiveScreenViewModel(auctionDto);
|
||||||
|
Product product;
|
||||||
|
ProductDetailsModel productDetailsModel;
|
||||||
|
ProductToAuctionDto activeMapping;
|
||||||
|
int activeProductId = 0;
|
||||||
|
int activeProductToAuctionId = 0;
|
||||||
|
decimal basePrice = 0;
|
||||||
|
decimal currentPrice = 0;
|
||||||
|
decimal nextStep = 0;
|
||||||
|
|
||||||
var product = await _productService.GetProductByIdAsync(auctionDto.ProductToAuctionDtos.FirstOrDefault().Id);
|
if (isAnyItemLive)
|
||||||
|
{
|
||||||
|
|
||||||
|
activeMapping = auctionDto.ProductToAuctionDtos.Where(x => x.AuctionStatus == AuctionStatus.Active).FirstOrDefault();
|
||||||
|
product = await _productService.GetProductByIdAsync(activeMapping.ProductId);
|
||||||
|
activeProductId = activeMapping.ProductId;
|
||||||
|
activeProductToAuctionId = activeMapping.Id;
|
||||||
|
productDetailsModel = await _productModelFactory.PrepareProductDetailsModelAsync(product);
|
||||||
|
basePrice = activeMapping.StartingPrice;
|
||||||
|
currentPrice = activeMapping.CurrentPrice;
|
||||||
|
nextStep = AuctionService.GetStepAmount(currentPrice);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
var productDetailsModel = await _productModelFactory.PrepareProductDetailsModelAsync(product);
|
else
|
||||||
|
{
|
||||||
|
activeMapping = null;
|
||||||
|
product = null;
|
||||||
|
activeProductId = 0;
|
||||||
|
activeProductToAuctionId = 0;
|
||||||
|
productDetailsModel = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
//I need product data
|
||||||
|
//create a more detailed model
|
||||||
|
|
||||||
|
|
||||||
|
model.IsAnyItemActive = isAnyItemLive;
|
||||||
|
model.AuctionId = auctionId;
|
||||||
|
model.CurrentProductToAuction = activeMapping;
|
||||||
|
model.ActiveProductId = activeProductId;
|
||||||
|
model.ActiveProductToAuctionId = activeProductToAuctionId;
|
||||||
|
model.ActiveProductDetails = productDetailsModel;
|
||||||
|
model.BasePrice = basePrice;
|
||||||
|
model.CurrentPrice = currentPrice;
|
||||||
|
model.LicitStep = nextStep;
|
||||||
|
model.BasePrice = basePrice;
|
||||||
|
model.CurrentPrice = currentPrice;
|
||||||
|
|
||||||
|
|
||||||
model.ProductDetails = productDetailsModel;
|
|
||||||
|
|
||||||
return View("~/Plugins/Misc.AuctionPlugin/Views/LiveScreen.cshtml", model);
|
return View("~/Plugins/Misc.AuctionPlugin/Views/LiveScreen.cshtml", model);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ public class ProductToAuctionDto : IProductToAuctionDto
|
||||||
|
|
||||||
public bool IsActiveItem => AuctionStatus is AuctionStatus.Active or AuctionStatus.FirstWarning or AuctionStatus.SecondWarning;
|
public bool IsActiveItem => AuctionStatus is AuctionStatus.Active or AuctionStatus.FirstWarning or AuctionStatus.SecondWarning;
|
||||||
|
|
||||||
|
public decimal BidPrice { get; set; }
|
||||||
|
|
||||||
public ProductToAuctionDto() { }
|
public ProductToAuctionDto() { }
|
||||||
public ProductToAuctionDto(ProductToAuctionMapping productToAuction) : this(productToAuction, 0/*AuctionService.GetStepAmount(productToAuction.BidPrice)*/) { }
|
public ProductToAuctionDto(ProductToAuctionMapping productToAuction) : this(productToAuction, 0/*AuctionService.GetStepAmount(productToAuction.BidPrice)*/) { }
|
||||||
|
|
||||||
|
|
@ -49,6 +51,7 @@ public class ProductToAuctionDto : IProductToAuctionDto
|
||||||
StartingPrice = productToAuction.StartingPrice;
|
StartingPrice = productToAuction.StartingPrice;
|
||||||
CurrentPrice = productToAuction.CurrentPrice;
|
CurrentPrice = productToAuction.CurrentPrice;
|
||||||
ProductAmount = productToAuction.ProductAmount;
|
ProductAmount = productToAuction.ProductAmount;
|
||||||
|
SortIndex = productToAuction.SortIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProductToAuctionMapping CreateMainEntity()
|
public ProductToAuctionMapping CreateMainEntity()
|
||||||
|
|
@ -62,6 +65,7 @@ public class ProductToAuctionDto : IProductToAuctionDto
|
||||||
mainEntity.StartingPrice = StartingPrice;
|
mainEntity.StartingPrice = StartingPrice;
|
||||||
mainEntity.CurrentPrice = CurrentPrice;
|
mainEntity.CurrentPrice = CurrentPrice;
|
||||||
mainEntity.ProductAmount = ProductAmount;
|
mainEntity.ProductAmount = ProductAmount;
|
||||||
|
mainEntity.SortIndex = SortIndex;
|
||||||
|
|
||||||
return mainEntity;
|
return mainEntity;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,47 +15,30 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[System.Text.Json.Serialization.JsonIgnore]
|
[System.Text.Json.Serialization.JsonIgnore]
|
||||||
public ProductToAuctionDto FirstProductToAuction { get; set; }
|
public ProductToAuctionDto CurrentProductToAuction { get; set; }
|
||||||
|
|
||||||
public ProductDetailsModel ProductDetails { get; set; }
|
public ProductDetailsModel ActiveProductDetails { get; set; }
|
||||||
|
|
||||||
public int ProductId { get; set; }
|
public bool IsAnyItemActive { get; set; }
|
||||||
|
public int ActiveProductId { get; set; }
|
||||||
public int ProductToAuctionId { get; set; }
|
|
||||||
public bool IsAdmin { get; set; }
|
|
||||||
public bool IsGuest { get; set; }
|
|
||||||
|
|
||||||
public int AuctionId { get; set; }
|
public int AuctionId { get; set; }
|
||||||
public bool IsItemActive { get; set; }
|
public int ActiveProductToAuctionId { get; set; }
|
||||||
public int CustomerId { get; set; }
|
public bool IsAdmin { get; set; }
|
||||||
|
public bool IsGuest { get; set; }
|
||||||
public string WidgetZone { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
#region debug fields to be removed
|
|
||||||
|
|
||||||
public decimal? BasePrice { get; set; }
|
public decimal? BasePrice { get; set; }
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region visible
|
|
||||||
public decimal LicitStep { get; set; }
|
public decimal LicitStep { get; set; }
|
||||||
public decimal? CurrentPrice { get; set; }
|
public decimal? CurrentPrice { get; set; }
|
||||||
public decimal BidPrice { get; set; }
|
|
||||||
|
|
||||||
#endregion visible
|
|
||||||
|
|
||||||
public LiveScreenViewModel() { }
|
public LiveScreenViewModel() { }
|
||||||
|
|
||||||
public LiveScreenViewModel(AuctionDto auctionDto) : this()
|
public LiveScreenViewModel(AuctionDto auctionDto) : this()
|
||||||
{
|
{
|
||||||
AuctionDto = auctionDto;
|
AuctionDto = auctionDto;
|
||||||
FirstProductToAuction = AuctionDto.ProductToAuctionDtos.First();
|
|
||||||
|
|
||||||
AuctionId = auctionDto.Id;
|
|
||||||
ProductId = FirstProductToAuction.ProductId;
|
|
||||||
ProductToAuctionId = FirstProductToAuction.Id;
|
|
||||||
IsItemActive = FirstProductToAuction.IsActiveItem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<div class="container-fluid">
|
<div class="container-fluid bg-primary" style="height: 100vh;">
|
||||||
@RenderBody()
|
@RenderBody()
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
|
|
@ -7,53 +7,24 @@
|
||||||
var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;
|
var gridPageSizes = EngineContext.Current.Resolve<Nop.Core.Domain.Common.AdminAreaSettings>().GridPageSizes;
|
||||||
Layout = "Auction/LiveScreenRoot.cshtml";
|
Layout = "Auction/LiveScreenRoot.cshtml";
|
||||||
//page title
|
//page title
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="row">
|
@{
|
||||||
|
if (Model.IsAnyItemActive)
|
||||||
|
{
|
||||||
|
|
||||||
|
<div id="auctionProductLiveScreenBox" class="row py-3">
|
||||||
<!-- Item Image -->
|
<!-- Item Image -->
|
||||||
<div class="col-lg-5 col-md-6 mb-4">
|
<div class="col-lg-4 col-md-6 mb-4">
|
||||||
<div class="card shadow-sm">
|
<div class="card border-0">
|
||||||
<img src="@Model.ProductDetails.DefaultPictureModel.FullSizeImageUrl" class="card-img-top img-fluid" alt="Auction Item Image">
|
<img src="@Model.ActiveProductDetails.DefaultPictureModel.FullSizeImageUrl" class="card-img-top img-fluid" alt="Auction Item Image">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="card bg-transparent">
|
||||||
<!-- 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">
|
<div class="card-body">
|
||||||
<h5 class="card-title mb-3">Bid History</h5>
|
<h5 class="card-title mb-3">Bid History</h5>
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table id="bidHistoryTable" class="table table-striped table-bordered">
|
<table id="bidHistoryTable" class="table table-striped bg-transparent">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
|
|
@ -70,27 +41,87 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Item Details -->
|
||||||
|
<div class="col-lg-8 col-md-6" style="height: 100vh;">
|
||||||
|
<div class="card border-0 bg-transparent h-100">
|
||||||
|
<div class="card-body border-0">
|
||||||
|
<h1 class="card-title">@Model.ActiveProductDetails.Name</h1>
|
||||||
|
<h2 class="text-muted mb-3">Created by: <span class="font-weight-bold">@Model.ActiveProductDetails.ProductManufacturers.FirstOrDefault().Name</span></h2>
|
||||||
|
<h3> Item no.: @Model.CurrentProductToAuction.SortIndex </h3>
|
||||||
|
<!-- Item Information -->
|
||||||
|
<ul class="list-group mb-3 border-0">
|
||||||
|
<li class="bg-transparent border-0 list-group-item d-flex justify-content-between align-items-center">
|
||||||
|
<span>Base price</span>
|
||||||
|
<span>@(String.Format("{0:c}", Model.BasePrice))</span>
|
||||||
|
</li>
|
||||||
|
<li class="bg-transparent border-0 list-group-item d-flex justify-content-between align-items-center">
|
||||||
|
<span>Actual licit step</span>
|
||||||
|
<span>@(String.Format("{0:c}", Model.LicitStep))</span>
|
||||||
|
</li>
|
||||||
|
<li class="bg-transparent border-0 list-group-item d-flex justify-content-between align-items-center">
|
||||||
|
@await Html.PartialAsync("../../../Views/Product/_ProductSpecifications.cshtml", Model.ActiveProductDetails.ProductSpecificationModel)
|
||||||
|
@* @{
|
||||||
|
|
||||||
|
var dataDictAttributes = new ViewDataDictionary(ViewData);
|
||||||
|
dataDictAttributes.TemplateInfo.HtmlFieldPrefix = $"attributes_{Model.ProductDetails.Id}";
|
||||||
|
@await Html.PartialAsync("../../../Views/Product/_ProductAttributes.cshtml", Model.ProductDetails, dataDictAttributes)
|
||||||
|
}
|
||||||
|
*@
|
||||||
|
</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="bg-transparent border-0 list-group-item">
|
||||||
|
<span class="font-weight-bold">Description:</span>
|
||||||
|
<p class="mb-0 mt-2 text-muted">
|
||||||
|
@Html.Raw(Model.ActiveProductDetails.FullDescription)
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer border-0 d-flex justify-content-between align-items-center ">
|
||||||
|
<span>Current state price</span>
|
||||||
|
<h3>@(String.Format("{0:c}", Model.CurrentPrice))</h3>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<div class="row mt-4">
|
||||||
|
<!-- Bid History Table -->
|
||||||
|
<div class="col-12">
|
||||||
|
<h1>@Model.AuctionDto.AuctionName</h1>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
<!-- Initialize DataTable -->
|
|
||||||
<script>
|
|
||||||
$(document).ready(function () {
|
|
||||||
$('#bidHistoryTable').DataTable({
|
<!-- Initialize DataTable -->
|
||||||
"pageLength": 10,
|
<script>
|
||||||
"ordering": true,
|
$(document).ready(function () {
|
||||||
"searching": true,
|
$('#bidHistoryTable').DataTable({
|
||||||
"info": true,
|
"pageLength": 10,
|
||||||
"lengthChange": false,
|
"ordering": true,
|
||||||
"columns": [
|
"searching": true,
|
||||||
{ "data": "#" },
|
"info": true,
|
||||||
{ "data": "Bidder" },
|
"lengthChange": false,
|
||||||
{ "data": "Bid Amount" },
|
"columns": [
|
||||||
{ "data": "Date" }
|
{ "data": "#" },
|
||||||
]
|
{ "data": "Bidder" },
|
||||||
});
|
{ "data": "Bid Amount" },
|
||||||
|
{ "data": "Date" }
|
||||||
|
]
|
||||||
});
|
});
|
||||||
</script>
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue