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

namespace PageAdmin.Web.Areas.Admin.Controllers
{
    public class MyReplyDataController : DefaultBaseController
    {
        public MyReplyDataController() : base("pa_reply_data_uid", "Work/")
        {
            base.ListDataExecuting = OnListExecuting;
        }

       private void OnListExecuting()
        {
            int uid = base.CurrentUser.Uid;
            base.MvcContext.SqlCondition = "uid=" + uid;
        }

        [HttpGet]
        public ActionResult Detail()
        {
            string table = Request.QueryString["table"];
            int detailId =StringHelper.Format<int>(Request.QueryString["detail_id"]);
            if (string.IsNullOrEmpty(table) || detailId <= 0)
            {
                return Content("无效的table参数或detail_id参数！");
            }
            InfoTableBLL infoTableBll = new InfoTableBLL();
            if(!infoTableBll.IsExists(table,true))
            {
                return Content("信息表："+ table+"已经不存在！");
            }
            InfoDataBLL infoDataBLL = new InfoDataBLL(table);
            dynamic infoData = infoDataBLL.GetData(detailId);
            if(infoData==null)
            {
                return Content("当前数据已经被删除！");
            }
            ViewBag.InfoData = infoData;
            ViewBag.InfoTable = table;
            return View();
        }
    }
}