using JXCMS.CMS.Attribute;
using JXCMS.CMS.Movie.Entity;
using Microsoft.AspNetCore.Mvc;

namespace JXCMS.CMS.Admin.Controllers
{
    [Area("Admin")]
    [AdminAuthentication]
    public class CollectionController : Controller
    {
        public IActionResult Index()
        {
            ViewBag.title = "采集地址";
            var website = WebSiteEntity.Select.ToList();
            ViewBag.website = website;
            return View();
        }

        [HttpPost]
        public IActionResult AddWebSite(WebSiteEntity webSiteEntity)
        {
            webSiteEntity.Save();
            return Redirect(Url.Action("Index"));
        }

        public IActionResult DeleteWebSite(int id)
        {
            return Redirect(Url.Action("Index"));
        }

        public IActionResult WebSiteDialog(int id)
        {
            WebSiteEntity webSiteEntity = null;
            if (id == 0)
            {
                webSiteEntity = new WebSiteEntity();
                ViewBag.title = "添加新网站";
            }
            else
            {
                webSiteEntity = WebSiteEntity.Find(id);
                ViewBag.title = "修改" + webSiteEntity.WebSiteName;
            }
            return View(webSiteEntity);
        }
    }
}