using Microsoft.AspNetCore.Mvc;
using Nop.Plugin.Misc.AuctionPlugin;
using Nop.Services.Catalog;
using Nop.Services.Cms;
using Nop.Services.Common;
using Nop.Web.Areas.Admin.Models.Orders;
using Nop.Web.Framework.Components;
using Nop.Web.Framework.Infrastructure;
using Nop.Web.Models.Catalog;
namespace Nop.Plugin.AuctionPlugin.Components
{
[ViewComponent(Name = "AuctionAdmin")]
public class AuctionAdminViewComponent : NopViewComponent
{
#region Fields
protected readonly IAddressService _addressService;
protected readonly IProductAttributeService _productAttributeService;
protected readonly IWidgetPluginManager _widgetPluginManager;
protected readonly AuctionSettings _auctionSettings;
#endregion
#region Ctor
public AuctionAdminViewComponent(IAddressService addressService,
IProductAttributeService productAttributeService,
IWidgetPluginManager widgetPluginManager,
AuctionSettings auctionSettings)
{
_addressService = addressService;
_productAttributeService = productAttributeService;
_widgetPluginManager = widgetPluginManager;
_auctionSettings = auctionSettings;
}
#endregion
#region Methods
///
/// Invoke the widget view component
///
/// Widget zone
/// Additional parameters
///
/// A task that represents the asynchronous operation
/// The task result contains the view component result
///
public async Task InvokeAsync(string widgetZone, object additionalData)
{
if (!await _widgetPluginManager.IsPluginActiveAsync(AuctionDefaults.SystemName))
return Content(string.Empty);
if (!_auctionSettings.Enabled)
return Content(string.Empty);
//if (additionalData is not ProductDetailsModel model)
// return Content(string.Empty);
var productId = 0;
if (widgetZone.Equals(AdminWidgetZones.ProductDetailsBlock))
productId = (additionalData as ProductDetailsModel).Id;
return View("~/Plugins/Misc.AuctionPlugin/Views/AdminProductAuctionSettingsBox.cshtml", productId.ToString());
}
#endregion
}
}