biztos kell még tesztelni

This commit is contained in:
Adam 2024-11-27 10:47:36 +01:00
parent 85c857de99
commit 034181c702
5 changed files with 233 additions and 74 deletions

View File

@ -1,5 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using ExCSS;
using Microsoft.AspNetCore.Mvc;
using Nop.Core;
using Nop.Core.Domain.Catalog;
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
using Nop.Plugin.Misc.AuctionPlugin.Domains.Entities;
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
@ -12,6 +14,9 @@ using Nop.Services.Logging;
using Nop.Web.Framework.Components;
using Nop.Web.Framework.Infrastructure;
using Nop.Web.Models.Catalog;
using Nop.Web.Framework.Mvc.Routing;
using DocumentFormat.OpenXml.EMMA;
using Nop.Services.Catalog;
namespace Nop.Plugin.Misc.AuctionPlugin.Components;
@ -26,7 +31,10 @@ public class AuctionPublicViewComponent : NopViewComponent
protected readonly AuctionService _auctionService;
protected readonly AuctionSettings _auctionSettings;
protected readonly ICustomerService _customerService;
protected readonly IWebHelper _webHelper;
protected readonly IProductService _productService;
protected readonly ILogger _logger;
protected readonly MyProductModelFactory _myProductModelFactory;
#endregion
@ -39,6 +47,9 @@ public class AuctionPublicViewComponent : NopViewComponent
AuctionService auctionService,
AuctionSettings auctionSettings,
ICustomerService customerService,
IWebHelper webHelper,
IProductService productService,
MyProductModelFactory myProductModelFactory,
ILogger logger)
{
_addressService = addressService;
@ -48,6 +59,9 @@ public class AuctionPublicViewComponent : NopViewComponent
_auctionService = auctionService;
_auctionSettings = auctionSettings;
_customerService = customerService;
_webHelper = webHelper;
_productService = productService;
_myProductModelFactory = myProductModelFactory;
_logger = logger;
}
@ -106,6 +120,7 @@ public class AuctionPublicViewComponent : NopViewComponent
var productId = productDetailsModel.Id;
var productToAuction = (await _auctionService.GetProductToAuctionDtosByProductIdAsync(productId)).FirstOrDefault();
if (productToAuction == null)
{
return Content(string.Empty);
@ -121,6 +136,50 @@ public class AuctionPublicViewComponent : NopViewComponent
//bool isActive = status == AuctionStatus.Active || status == AuctionStatus.FirstWarning || status == AuctionStatus.SecondWarning;
//bool isFirstWarning = status == AuctionStatus.FirstWarning;
var detailedAuctionDto = (await _auctionService.GetAuctionDtoByIdAsync(productToAuction.AuctionId, true, false));
ProductToAuctionDto nextProductToAuction;
ProductToAuctionDto lastProductToAuction;
string nextUrl = "";
string lastUrl = "";
string nextImageUrl = "";
string lastImageUrl = "";
string nextProductName = "";
string lastProductName = "";
if (productToAuction.SortIndex < detailedAuctionDto.ProductToAuctionDtos.Count)
{
nextProductToAuction = detailedAuctionDto.ProductToAuctionDtos.Where(x => x.SortIndex == productToAuction.SortIndex + 1).FirstOrDefault();
var nextProductId = nextProductToAuction.ProductId;
var nextProduct = await _productService.GetProductByIdAsync(nextProductId);
var nextDetails = await _myProductModelFactory.PrepareProductDetailsModelAsync(nextProduct);
nextUrl = Url.RouteUrl<Product>(new { nextDetails.SeName }, _webHelper.GetCurrentRequestProtocol()).ToLowerInvariant();
nextImageUrl = nextDetails.DefaultPictureModel.FullSizeImageUrl;
nextProductName = nextDetails.SeName;
}
else
{
nextProductToAuction = null;
}
if (productToAuction.SortIndex > 1)
{
lastProductToAuction = detailedAuctionDto.ProductToAuctionDtos.Where(x => x.SortIndex == productToAuction.SortIndex - 1).FirstOrDefault();
var lastProductId = lastProductToAuction.ProductId;
var lastProduct = await _productService.GetProductByIdAsync(lastProductId);
var lastDetails = await _myProductModelFactory.PrepareProductDetailsModelAsync(lastProduct);
lastUrl = Url.RouteUrl<Product>(new { lastDetails.SeName }, _webHelper.GetCurrentRequestProtocol()).ToLowerInvariant();
lastImageUrl = lastDetails.DefaultPictureModel.FullSizeImageUrl;
lastProductName = lastDetails.SeName;
}
else
{
lastProductToAuction = null;
}
productBidBoxViewModel.IsAdmin = await _customerService.IsAdminAsync(customer);
productBidBoxViewModel.IsGuest = await _customerService.IsGuestAsync(customer);
@ -133,6 +192,13 @@ public class AuctionPublicViewComponent : NopViewComponent
//productBidBoxViewModel.AuctionId = auctionId;
productBidBoxViewModel.CustomerId = customer.Id;
productBidBoxViewModel.ProductId = productDetailsModel.Id;
//productBidBoxViewModel.NextProductUrl = Url.RouteUrl("Product", productDetailsModel.SeName);
productBidBoxViewModel.NextProductUrl = nextUrl;
productBidBoxViewModel.LastProductUrl = lastUrl;
productBidBoxViewModel.LastProductImageUrl = lastImageUrl;
productBidBoxViewModel.NextProductImageUrl = nextImageUrl;
productBidBoxViewModel.LastProductName = lastProductName;
productBidBoxViewModel.NextProductName = nextProductName;
productBidBoxViewModel.LicitStep = AuctionService.GetStepAmount(productToAuction.CurrentPrice); //add calculation
productBidBoxViewModel.NextBidPrice = productToAuction.CurrentPrice + productBidBoxViewModel.LicitStep;

View File

@ -72,7 +72,51 @@
var publicProductBidBox = document.getElementById("publicProductBidBox");
var liveScreen = document.getElementById("auctionProductLiveScreenBox");
if (!liveScreen) {
toastr.success(`<div class="item bidToast"><p>${productToAuctionDto.auctionStatus}</p><p>${productToAuctionDto.id}</p></div>`, "Status changed", {
var messageTitle = "";
var messageText = "";
var messageColor = "";
switch (productToAuctionDto.auctionStatus) {
case AuctionStatus.None:
messageTitle = `Item reset`;
messageText = `The bids on item with index ${myObject.auctionDto.productToAuctionDtos[0].SortIndex} has been resetted`;
messageColor = "#6c757d";
break;
case AuctionStatus.Active:
messageTitle = `Item activated`;
messageText = `The bids on item with index ${myObject.auctionDto.productToAuctionDtos[0].SortIndex} has been activated`;
messageColor = "#4caf50";
break;
case AuctionStatus.FirstWarning:
messageTitle = `First warning!`;
messageText = `Hurry up! If no more bids, this item will be closed soon!`;
messageColor = "#ffc107";
break;
case AuctionStatus.SecondWarning:
messageTitle = `Second warning!`;
messageText = `Hurry up! If no more bids, this item will be closed soon!`;
messageColor = "#dc3545";
break;
case AuctionStatus.Pause:
messageTitle = `Administrative message`;
messageText = `The administrator has suspended the auction, it will go on soon probably`;
messageColor = "#6c757d";
break;
case AuctionStatus.Sold:
messageTitle = `Item sold!`;
messageText = `The item has been sold, we are transitioning to the next item!`;
messageColor = "#4caf50";
break;
case AuctionStatus.NotSold:
messageTitle = `Item closed!`;
messageText = `The item has been closed, we are transitioning to the next item!`;
messageColor = "#6c757d";
break;
default:
break;
}
toastr.success(`<div class="item bidToast"><p>${messageText}</p></div>`, messageTitle, {
"closeButton": true,
"positionClass": "toast-top-right",
"newestOnTop": true,
@ -88,7 +132,7 @@
"showMethod": animation,
"hideMethod": "fadeOut"
});
$('.toast-success').css("background-color", "#4caf50");
$('.toast-success').css("background-color", messageColor);
}
if (publicProductBidBox) {
handleAuctionUpdate(myObject);

View File

@ -1,4 +1,5 @@
using Newtonsoft.Json;
using ExCSS;
using Newtonsoft.Json;
using Nop.Plugin.Misc.AuctionPlugin.Domains.Dtos;
using Nop.Plugin.Misc.AuctionPlugin.Domains.Enums;
using Nop.Web.Framework.Models;
@ -12,12 +13,12 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
{
public record ProductBidBoxViewModel: BaseNopModel
{
[JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
//[JsonIgnore]
//[System.Text.Json.Serialization.JsonIgnore]
public AuctionDto AuctionDto { get; set; }
[JsonIgnore]
[System.Text.Json.Serialization.JsonIgnore]
//[JsonIgnore]
//[System.Text.Json.Serialization.JsonIgnore]
public ProductToAuctionDto FirstProductToAuction { get; set; }
public int ProductToAuctionId { get; set; }
@ -29,6 +30,15 @@ namespace Nop.Plugin.Misc.AuctionPlugin.Models
public bool IsItemActive => FirstProductToAuction.IsActiveItem;
public AuctionStatus AuctionStatus { get; set; }
public int ProductId { get; set; }
public string NextProductUrl { get; set; }
public string NextProductImageUrl { get; set; }
public string NextProductName { get; set; }
public string LastProductUrl { get; set; }
public string LastProductImageUrl { get; set; }
public string LastProductName { get; set; }
public int CustomerId { get; set; }
public string WidgetZone { get; set; }

View File

@ -17,7 +17,7 @@
<div class="row py-3">
<!-- Item Image -->
<div class="col-lg-4 col-md-6 mb-4">
<div class="col-lg-4 col-md-6 mb-4" style="height: calc(100vh - 100px);">
<div class="card border-0">
<img src="@Model.ActiveProductDetails.DefaultPictureModel.FullSizeImageUrl" class="card-img-top img-fluid" alt="Auction Item Image">
</div>
@ -42,7 +42,7 @@
</div>
</div>
<!-- Item Details -->
<div class="col-lg-8 col-md-6" style="height: 100vh;">
<div class="col-lg-8 col-md-6" style="height: calc(100vh - 100px);">
<div class="card border-0 bg-transparent h-100">
<div class="card-header border-0 bg-transparent">
<div class="row">
@ -91,6 +91,11 @@
</div>
</div>
</div>
<div class="row" style="height:100px; position: fixed; bottom:0px;">
LOGO
</div>
}
else
{

View File

@ -12,7 +12,41 @@
var bgClass = Model.AuctionDto.ProductToAuctionDtos.FirstOrDefault().WinnerCustomerId == Model.CustomerId ? "bg-success" : "bg-primary";
bool bidButtonActive = Model.IsItemActive && (Model.AuctionDto.ProductToAuctionDtos.FirstOrDefault().WinnerCustomerId == Model.CustomerId && !Model.IsAdmin) ? true : false;
string title = Model.AuctionDto.ProductToAuctionDtos.FirstOrDefault().WinnerCustomerId == Model.CustomerId ? "Your bid is leading" : "Place a bid!";
<div class="d-flex justify-content-between" id="otherAuctionItems">
<a href="@(string.IsNullOrEmpty(Model.LastProductUrl) ? "#" : Model.LastProductUrl)" @(string.IsNullOrEmpty(Model.LastProductUrl) ? "disabled" : string.Empty)>
<div class="card mb-3" style="max-width: 540px;">
<div class="row g-0">
<div class="col-md-4">
<img src="@(string.IsNullOrEmpty(Model.LastProductImageUrl) ? "https://placehold.co/400" : Model.LastProductImageUrl)" class="img-fluid rounded-start" alt="...">
</div>
<div class="col-md-8">
<div class="card-body">
<h5 class="card-title">@(string.IsNullOrEmpty(Model.LastProductUrl) ? "Start of list" : "Back to last")</h5>
<p class="card-text">@(string.IsNullOrEmpty(Model.LastProductName) ? "---" : Model.LastProductName)</p>
</div>
</div>
</div>
</div>
</a>
<a href="@(string.IsNullOrEmpty(Model.NextProductUrl) ? "#" : Model.NextProductUrl)" @(string.IsNullOrEmpty(Model.NextProductUrl) ? "disabled" : string.Empty)>
<div class="card mb-3" style="max-width: 540px;">
<div class="row g-0">
<div class="col-md-4">
<img src="@(string.IsNullOrEmpty(Model.NextProductImageUrl) ? "https://placehold.co/400" : Model.NextProductImageUrl)" class="img-fluid rounded-start" alt="...">
</div>
<div class="col-md-8">
<div class="card-body">
<h5 class="card-title">@(string.IsNullOrEmpty(Model.NextProductUrl) ? "End of list" : "Coming up next...")</h5>
<p class="card-text">@(string.IsNullOrEmpty(Model.NextProductName) ? "---" : Model.NextProductName)</p>
</div>
</div>
</div>
</div>
</a>
</div>
<div id="publicProductBidBox" class="p-3 @bgClass text-white">
<h4 id="bidBoxTitle">@title</h4>
<div class="d-flex justify-content-between">