Example #1
0
        public static void Create(MenuDataModel menu)
        {
            MySqlConnection connection = new MySqlConnection(ConfigurationManager.AppSettings[BusinessUtilies.Const.Database.AppSetting]);
            MySqlDataAdapter adapter = new MySqlDataAdapter("Core_CreateMenu", connection);
            adapter.SelectCommand.CommandType = CommandType.StoredProcedure;

            MySqlParameter paramID = new MySqlParameter("pID", menu.ID);
            paramID.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramID);
            MySqlParameter paramName = new MySqlParameter("pName", menu.Name);
            paramName.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramName);
            MySqlParameter paramURL = new MySqlParameter("pURL", menu.URL);
            paramURL.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramURL);
            MySqlParameter paramMenuOrder = new MySqlParameter("pMenuOrder", menu.MenuOrder);
            paramMenuOrder.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramMenuOrder);
            MySqlParameter paramMenuID = new MySqlParameter("pMenuID", menu.MenuID);
            paramMenuID.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramMenuID);

            DataTable results = new DataTable();
            adapter.Fill(results);
        }
Example #2
0
        public override void Create(MenuDataModel menu)
        {
            if (HttpContext.Current.Session["menuParentID"] != null)
            {
                menu.MenuID = Convert.ToInt32(HttpContext.Current.Session["menuParentID"]);
            }

            base.Create(menu);
        }
Example #3
0
        public virtual void Update(MenuDataModel menu)
        {
            if (menu.ID > 0)
            {

                MenuDAL.Update(menu);
            }
            else
            {
                throw new Exception("Page not found");
            }
        }
        public ActionResult Edit(MenuDataModel menu)
        {
            MenuBO.GetInstance().Update(menu);

            if (Session["menuParentID"] != null)
            {
                return RedirectToAction("Index", new { id = Convert.ToInt32(Session["menuParentID"]) });
            }
            else
            {
                return RedirectToAction("Index");
            }
        }
Example #5
0
        public static List<MenuDataModel> GetMenuItems(string menuName)
        {
            List<MenuDataModel> menus = new List<MenuDataModel>();

            MySqlConnection connection = new MySqlConnection(ConfigurationManager.AppSettings[BusinessUtilies.Const.Database.AppSetting]);
            MySqlDataAdapter adapter = new MySqlDataAdapter("Core_GetMenuItems", connection);
            adapter.SelectCommand.CommandType = CommandType.StoredProcedure;

            MySqlParameter paramID = new MySqlParameter("pMenuName", menuName);
            paramID.Direction = ParameterDirection.Input;
            adapter.SelectCommand.Parameters.Add(paramID);

            DataTable results = new DataTable();

            adapter.Fill(results);

            foreach (DataRow item in results.Rows)
            {
                MenuDataModel menu = new MenuDataModel();

                if (item["ID"].GetType() != typeof(DBNull))
                {
                    menu.ID = Convert.ToInt32(item["ID"]);
                }
                if (item["Name"].GetType() != typeof(DBNull))
                {
                    menu.Name = Convert.ToString(item["Name"]);
                }
                if (item["URL"].GetType() != typeof(DBNull))
                {
                    menu.URL = Convert.ToString(item["URL"]);
                }
                if (item["MenuOrder"].GetType() != typeof(DBNull))
                {
                    menu.MenuOrder = Convert.ToInt32(item["MenuOrder"]);
                }
                if (item["MenuID"].GetType() != typeof(DBNull))
                {
                    menu.MenuID = Convert.ToInt32(item["MenuID"]);
                }

                menus.Add(menu);
            }

            return menus;
        }
Example #6
0
        public static MenuDataModel Get(int id)
        {
            MenuDataModel menu = null;

            MySqlConnection connection = new MySqlConnection(ConfigurationManager.AppSettings[BusinessUtilies.Const.Database.AppSetting]);
            MySqlDataAdapter adapter = new MySqlDataAdapter("Core_GetMenuByID", connection);
            MySqlParameter paramID = new MySqlParameter("pId", id);
            paramID.Direction = ParameterDirection.Input;
            adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
            adapter.SelectCommand.Parameters.Add(paramID);

            DataTable results = new DataTable();

            adapter.Fill(results);

            if (results.Rows.Count > 0)
            {
                DataRow item = results.Rows[0];
                menu = new MenuDataModel();

                if (item["ID"].GetType() != typeof(DBNull))
                {
                    menu.ID = Convert.ToInt32(item["ID"]);
                }
                if (item["Name"].GetType() != typeof(DBNull))
                {
                    menu.Name = Convert.ToString(item["Name"]);
                }
                if (item["URL"].GetType() != typeof(DBNull))
                {
                    menu.URL = Convert.ToString(item["URL"]);
                }
                if (item["MenuOrder"].GetType() != typeof(DBNull))
                {
                    menu.MenuOrder = Convert.ToInt32(item["MenuOrder"]);
                }
                if (item["MenuID"].GetType() != typeof(DBNull))
                {
                    menu.MenuID = Convert.ToInt32(item["MenuID"]);
                }
            }

            return menu;
        }
Example #7
0
        public static List<MenuDataModel> GetParentMenus()
        {
            List<MenuDataModel> menus = new List<MenuDataModel>();

            MySqlConnection connection = new MySqlConnection(ConfigurationManager.AppSettings[BusinessUtilies.Const.Database.AppSetting]);
            MySqlDataAdapter adapter = new MySqlDataAdapter("GetParentMenus", connection);
            DataTable results = new DataTable();

            adapter.Fill(results);

            foreach (DataRow item in results.Rows)
            {
                MenuDataModel menu = new MenuDataModel();

                if (item["ID"].GetType() != typeof(DBNull))
                {
                    menu.ID = Convert.ToInt32(item["ID"]);
                }
                if (item["Name"].GetType() != typeof(DBNull))
                {
                    menu.Name = Convert.ToString(item["Name"]);
                }
                if (item["URL"].GetType() != typeof(DBNull))
                {
                    menu.URL = Convert.ToString(item["URL"]);
                }
                if (item["MenuOrder"].GetType() != typeof(DBNull))
                {
                    menu.MenuOrder = Convert.ToInt32(item["MenuOrder"]);
                }
                if (item["MenuID"].GetType() != typeof(DBNull))
                {
                    menu.MenuID = Convert.ToInt32(item["MenuID"]);
                }

                menus.Add(menu);
            }

            return menus;
        }
Example #8
0
 public virtual void Create(MenuDataModel menu)
 {
     MenuDAL.Create(menu);
 }
Example #9
0
        public override void Update(MenuDataModel menu)
        {
            CacheManager cache = CacheManager.GetInstance();
            cache.UpdateObject<MenuDataModel>(menu);

            base.Update(menu);
        }