using PageAdmin.Utils;
using System.Web.Mvc;
using PageAdmin.BLL;

namespace PageAdmin.Web.Areas.Admin.Controllers
{


    public class MemberGroupController : DefaultBaseController
    {
        public MemberGroupController():base("pa_member_group", "User")
        {
            base.MvcContext.IncludeCustomField = true;
            base.MvcContext.ListOrder = "rank asc";
            base.DeleteExecuting = OnDeleteExecuting;
            base.DeleteExecuted = DeleteRelative;
            base.UpdateListExecuting = OnUpdateListExecuting;
            base.CheckRepeatFieldDic.Add("rank", "会员等级");
        }

        private void OnDeleteExecuting()
        {
            base.MvcContext.SqlCondition= "isDefault = 0";
        }

        /// <summary>
        /// 删除相关
        /// </summary>
        private void DeleteRelative()
        {
            int id = base.MvcContext.DetailId;
            MemberGroupBLL memberGroupBLL = new MemberGroupBLL();
            memberGroupBLL.DeleteRelative(id);
        }

        private void OnUpdateListExecuting()
        {
            base.UpdateDbKeyValues.Add("rank", StringHelper.Format<int>(Request.Form["rank"]));
        }

        [HttpGet]
        [NotCheckMenuItemPermissions]
        public ActionResult Select()
        {
            return View();
        }
    }
}