using Hncore.Pass.Vpn.Service;
using Home.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Hncore.Infrastructure.Extension;
namespace Home.Controllers
{
   
    public class HomeController : MvcBaseController
    {
        ProductService m_ProductService;

        ArticleService m_ArticleService;
        ProductOrderService m_ProductOrderService;

        public HomeController(ProductService _ProductService, ArticleService _ArticleService, ProductOrderService _ProductOrderService)
        {
            m_ProductService = _ProductService;
            m_ArticleService = _ArticleService;
            m_ProductOrderService = _ProductOrderService;
        }
        [Route("/")]
        public async Task<IActionResult> Index()
        {
           var prodectList=await m_ProductService.Query(m=>m.OnLine==1).ToListAsync();
            var model = prodectList.MapsTo<ProductModel>();
            return View(model);
        }
        [Route("/h")]
        public IActionResult Test()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }

        [Route("/Test1")]
        public async Task Test1()
        {
          await  m_ProductOrderService.TestProcessOrderAccount();
        }
    }
}
