using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using RFrameGenerate.BLL;
using RFrameGenerate.Model;

namespace jiouosdp.Areas.Keywords.Controllers
{
    public class DefaultReplyController : Controller
    {
        //
        // GET: /Keywords/DefaultReply/

        [PF(PCode.WeiXinManage.DefaultReply)]
        public ActionResult Index()
        {
            return View();
        }

        public JsonResult GetKeyWordList(GridModel gridModel)
        {
            //var klist = KeywordsManage.GetKeyWordList(gridModel, RFrameGenerate.BLL.DictionaryConst.WeiXinAutoReply.ReplyKeyword.Default);

            //gridModel.datarows = (klist.Select(c => c.MaterialGuid != null ? new
            //{
            //    id = c.KeywordGuid,
            //    cell = new object[]
            //        {
            //            MaterialsManage.GetMaterialList(c.MaterialGuid.Value).Name,
            //            DictionaryConst.WeiXinAutoReply.MaterialType.GetMaterialByState(MaterialsManage.GetMaterialList(c.MaterialGuid.Value).MaterialType),
            //            c.MaterialGuid,
            //            ""
            //        }
            //} : null).ToArray());

            var klist = KeywordsManage.GetKeyList(RFrameGenerate.BLL.DictionaryConst.WeiXinAutoReply.ReplyKeyword.Default);

            gridModel.datarows = (klist.Select(c => new
            {
                id = c.KeywordGuid,
                cell = new object[]
                    {
                        c.Name,
                        DictionaryConst.WeiXinAutoReply.MaterialType.GetMaterialByState( c.MaterialType),
                        c.MaterialGuid
                    }
            }).ToArray());

            return Json(gridModel.PackagePageModel());
        }


    }
}
