131 lines
4.2 KiB
Plaintext
131 lines
4.2 KiB
Plaintext
@model ProductBidBoxViewModel
|
|
@inject IJsonHelper JsonHelper;
|
|
|
|
@* @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(myObj) as String) *@
|
|
|
|
|
|
@{
|
|
if (!Model.IsGuest)
|
|
{
|
|
<div id="publicProductBidBox" class="p-3 bg-primary text-white">
|
|
<h4>This item is under auction!</h4>
|
|
<div class="d-flex justify-content-between">
|
|
<div>
|
|
<strong>Base Price:</strong>
|
|
<span class="value">
|
|
@String.Format("{0:c}", Model.BasePrice)
|
|
@* @(decimal?.Round(Model.BasePrice, 2, MidpointRounding.AwayFromZero)) *@
|
|
</span>
|
|
</div>
|
|
<div>
|
|
<strong>Bid Step:</strong>
|
|
<span class="value">@String.Format("{0:c}", Model.LicitStep)</span>
|
|
</div>
|
|
<div>
|
|
<button id="signalRBidButton" class="btn btn-success" style="text-transform: uppercase;" type="button">
|
|
Bid @String.Format("{0:c}", Model.BidPrice)
|
|
</button>
|
|
@* <button id="bidButton" class="btn btn-success">
|
|
|
|
Bid @String.Format("{0:c}", Model.BidPrice)
|
|
</button> *@
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@* <button id="testButton" class="btn btn-success">
|
|
TestButton
|
|
</button> *@
|
|
|
|
<div id="bidFeedback" class="mt-3"></div>
|
|
</div>
|
|
|
|
|
|
if (Model.IsAdmin)
|
|
{
|
|
<div id="publicProductBidBoxAdmin" class="p-3 bg-primary text-white">
|
|
<h4>Manage auction!</h4>
|
|
<div id="bidBoxAdminButtons" class="d-flex justify-content-between mb-3">
|
|
<button id="signalRBidButton" class="btn btn-scondary" style="text-transform: uppercase;" type="button">
|
|
Activate item
|
|
</button>
|
|
<button id="signalRBidButton" class="btn btn-warning" style="text-transform: uppercase;" type="button">
|
|
First warning
|
|
</button>
|
|
</div>
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<p>No access to admin level buttons</p>
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
<div id="publicProductBidBoxGuest" class="p-3 bg-primary text-white">
|
|
<h4>This item is under auction!</h4>
|
|
<div id="bidBoxGuestMessage" class="d-flex justify-content-between mb-3">
|
|
|
|
<p>Please log in or register to participate!</p>
|
|
</div>
|
|
</div>
|
|
}
|
|
}
|
|
|
|
<script>
|
|
var pageViewModel = undefined;
|
|
$(document).ready(function () {
|
|
|
|
pageViewModel = @Html.Raw(Json.Serialize(Model));
|
|
console.log(pageViewModel);
|
|
console.log(pageViewModel.WidgetZone);
|
|
console.log(typeof sendMessageToServer);
|
|
|
|
$("#signalRBidButton").on("click", function () {
|
|
|
|
document.getElementById("signalRBidButton").disabled = true;
|
|
event.preventDefault();
|
|
|
|
var bidMessage = {
|
|
ProductAuctionMappingId: pageViewModel.ProductToAuctions,
|
|
AuctionId: pageViewModel.AuctionId,
|
|
BidPrice: pageViewModel.BidPrice,
|
|
ProductId: pageViewModel.ProductId,
|
|
CustomerId: pageViewModel.CustomerId
|
|
};
|
|
|
|
sendMessageToServer("BidRequestMessage", bidMessage);
|
|
|
|
return false;
|
|
});
|
|
|
|
|
|
});
|
|
|
|
function refreshPublicBidBox(data) {
|
|
|
|
|
|
var widgetPriceElement = document.getElementById("price-value-" + pageViewModel.ProductId);
|
|
var budButtonElement = document.getElementById("signalRBidButton");
|
|
|
|
if (widgetPriceElement) {
|
|
widgetPriceElement.textContent = data.bidPrice; // Update the price
|
|
|
|
pageViewModel.BidPrice = Number(data.bidPrice) + Number(data.nextStepAmount);
|
|
budButtonElement.textContent = pageViewModel.BidPrice.toFixed(2);
|
|
|
|
// if (pageViewModel.CustomerId == data.CustomerId) {
|
|
|
|
// }
|
|
|
|
console.log(`WidgetPrice updated to: ${data.bidPrice}`);
|
|
budButtonElement.disabled = false;
|
|
} else {
|
|
console.warn("Element with ID 'WidgetPrice' not found in the DOM.");
|
|
}
|
|
}
|
|
|
|
|
|
</script> |