using PageAdmin.Common;
using PageAdmin.Utils.ORM;
using PageAdmin.Utils;
using PageAdmin.Web;
using System.Web.Mvc;

namespace PageAdmin.Areas.Member
{
    public class MemberAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "Member";
            }
        }

        public override void RegisterArea(AreaRegistrationContext context)
        {
            string memberPath = "member/";
            string memberDomain = SystemConfig.Get().MemberDomain;
            if (string.IsNullOrEmpty(memberDomain))
            {
                memberDomain = SystemConfig.Get().Domain;
            }
            else
            {
                memberPath = "";
            }
            context.MapRoute(
                        "member_area_defaul_route",
                        memberPath + "{controller}/{action}/{id}",
                        new {controller = "Default", action = "Index", id = UrlParameter.Optional },
                        new {domainConstraint = new DomainConstraint(memberDomain), areaConstraint = new AreaConstraint("Member") },
                        new string[] { "PageAdmin.Web.Areas.Member.Controllers" }
                        );

        }
    }
}