using Microsoft.AspNetCore.Mvc;
using Nop.Web.Framework.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nop.Plugin.Misc.FruitBankPlugin.Components
{
    
    [ViewComponent(Name = "ProductAIWidget")]
    public class ProductAIWidgetViewComponent : NopViewComponent
    {
        public IViewComponentResult Invoke(string widgetZone, object additionalData)
        {
            if(additionalData is Nop.Web.Models.Catalog.ProductOverviewModel)
            {
                var product = additionalData as Nop.Web.Models.Catalog.ProductOverviewModel;

                if (product == null)
                    return Content(""); // ne rendereljen semmit, ha nincs product
                return View("~/Plugins/Misc.FruitBankPlugin/Views/ProductAIListWidget.cshtml", product);
            }
            else if (additionalData is Nop.Web.Models.Catalog.ProductDetailsModel)
            {
                var product = additionalData as Nop.Web.Models.Catalog.ProductDetailsModel;

                if (product == null)
                    return Content(""); // ne rendereljen semmit, ha nincs product
                return View("~/Plugins/Misc.FruitBankPlugin/Views/ProductAIWidget.cshtml", product);
            }
            else {
                return Content(""); // ne rendereljen semmit, ha nem productDetailModel vagy productOverviewModel
            }
            
        }
    }
}
