using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PageAdmin.Common;
using PageAdmin.BLL;using PageAdmin.Filter;

namespace PageAdmin.Web.Areas.Admin.Controllers
{
    public class CollectionContentController : BaseController
    {
        public CollectionContentController() : base("pa_collection_content", "Tool")
        {
            base.MvcContext.SqlCondition = "collection_id=" + System.Web.HttpContext.Current.Request.QueryString["collection_id"];
        }
        [HttpGet]
        public override ActionResult Edit()
        {
            CollectionBLL Bll = new CollectionBLL();
            int collection_id = StringHelper.Format<int>(Request.QueryString["collection_id"]);
            int id = StringHelper.Format<int>(Request.QueryString["id"]);
            ViewBag.Fields = Bll.GetCollectionFields(collection_id);
            return View("Add");
        }
        [HttpPost]
        public JsonResult DeleteWhole(FormCollection form)
        {
            TipsInfo tipsInfo = new TipsInfo();
            int collection_id = StringHelper.Format<int>(form["collection_id"]);
            if (collection_id==0)
            {
                tipsInfo.State = 0;
                tipsInfo.Msg = "collection_id参数有误";
                return Json(tipsInfo);
            }
            DbContext.Delete("pa_collection_content", "collection_id="+ collection_id);
            return Json(tipsInfo);
        }
    }
}