39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using Nop.Plugin.Misc.AuctionPlugin.Services;
|
|
using Nop.Services.Catalog;
|
|
using Nop.Web.Models.Catalog;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Nop.Plugin.Misc.AuctionPlugin.Models
|
|
{
|
|
public record AuctionProductModel : ProductDetailsModel
|
|
{
|
|
protected readonly MyProductModelFactory _factory;
|
|
protected readonly IProductService _productService;
|
|
|
|
public AuctionProductModel(){}
|
|
|
|
public AuctionProductModel(ProductDetailsModel dModel, MyProductModelFactory factory, IProductService productService)
|
|
: base(dModel)
|
|
{
|
|
_factory = factory;
|
|
_productService = productService;
|
|
}
|
|
|
|
public static async Task<AuctionProductModel> CreateAsync(
|
|
ProductOverviewModel oModel,
|
|
MyProductModelFactory factory,
|
|
IProductService productService)
|
|
{
|
|
|
|
var product = await productService.GetProductByIdAsync(oModel.Id);
|
|
var detailsModel = await factory.PrepareProductDetailsModelAsync(product);
|
|
|
|
return new AuctionProductModel(detailsModel, factory, productService);
|
|
}
|
|
}
|
|
}
|