using PushPlatform.Data.MvcModels;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Text;

namespace PushPlatform.Data.Bll
{
    public partial class BllSysMenu
    {

        #region Service Bll

        #region 获取项目对应的菜单
        /// <summary>
        /// 项目Id
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>
        public List<MenuModel> GetMenu(string projectId)
        {
            DaoAchieve.SysMenuDaoAchieve daoMenuDal = new DaoAchieve.SysMenuDaoAchieve();
            return daoMenuDal.GetMenu(projectId);
        }
        #endregion

        #region 获取菜单的HTML
        public string GetMenu(List<MenuModel> menu)
        {
            string url = ConfigurationManager.AppSettings["webUrl"];
            try
            {
                StringBuilder sb = new StringBuilder();

                if (menu != null && menu.Count > 0)
                {
                    sb.Append("<ul class=\"nnav clearfix\">");
                    foreach (var item in menu)
                    {
                        sb.Append("<li><a href=\"" + url.ToLower() + item.MenuUrl.ToLower() + "\">" + item.MenuName + "</a>");

                        sb.Append("</li>");
                    }
                    sb.Append("</ul>");

                    return sb.ToString();
                }
                else
                {
                    return string.Empty;
                }
            }
            catch (Exception ex)
            {
                return null;
            }
        }
        #endregion

        #endregion
    }
}