Пример #1
0
 public ActionResult AddMenuItem(MenuItem m_MenuItem)
 {
     if (ModelState.IsValid)
     {
         MenuItemRepository.Create(m_MenuItem);
         return RedirectToAction("MenuItems", "Menu", new { id = m_MenuItem.ParentId });
     }
     else
     {
         ViewBag.ParentId = m_MenuItem.ParentId;
         return View("AddMenuItem", m_MenuItem);
     }
 }
Пример #2
0
        public static void Create(MenuItem m_MenuItem)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            int sortOrder = getSortOrder(m_MenuItem.ParentId);

            string queryString = "INSERT INTO CMS_MenuItems(parentId, menuItemName, linkUrl, pageWorkFlowState, sortOrder) VALUES(@parentId, @menuItemName, @linkUrl, 0, @sortOrder)";
            SqlCommand insertMenuItem = new SqlCommand(queryString, conn);
            insertMenuItem.Parameters.AddWithValue("parentId", m_MenuItem.ParentId);
            insertMenuItem.Parameters.AddWithValue("menuItemName", m_MenuItem.MenuItemName);
            insertMenuItem.Parameters.AddWithValue("linkUrl", m_MenuItem.LinkUrl);
            insertMenuItem.Parameters.AddWithValue("sortOrder", sortOrder);
            insertMenuItem.ExecuteNonQuery();

            conn.Close();
        }
Пример #3
0
 public ActionResult AddMenuItem(int id)
 {
     ViewBag.ParentId = id;
     MenuItem m_MenuItem = new MenuItem();
     return View("AddMenuItem", m_MenuItem);
 }
Пример #4
0
 public ActionResult EditMenuItem(MenuItem m_MenuItem)
 {
     if (ModelState.IsValid)
     {
         MenuItemRepository.Update(m_MenuItem);
         return RedirectToAction("MenuItems", "Menu", new { id = m_MenuItem.ParentId });
     }
     else
     {
         return View("EditMenuItem", m_MenuItem);
     }
 }
Пример #5
0
        public static List<MenuItem> RetrieveAll(int id)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "SELECT * FROM CMS_MenuItems WHERE parentId = @parentId AND pageWorkFlowState != 4 ORDER BY sortOrder";
            SqlCommand getMenuItems = new SqlCommand(queryString, conn);
            getMenuItems.Parameters.AddWithValue("parentId", id);
            SqlDataReader menuDataReader = getMenuItems.ExecuteReader();

            List<MenuItem> m_MenuItems = new List<MenuItem>();

            while (menuDataReader.Read())
            {
                MenuItem tempMenuItem = new MenuItem();
                tempMenuItem.Id = menuDataReader.GetInt32(0);
                tempMenuItem.ParentId = menuDataReader.GetInt32(1);
                tempMenuItem.MenuItemName = menuDataReader.GetString(2);
                tempMenuItem.LinkUrl = menuDataReader.GetString(3);
                tempMenuItem.PageWorkFlowState = menuDataReader.GetInt32(4);

                m_MenuItems.Add(tempMenuItem);
            }

            conn.Close();
            return m_MenuItems;
        }
Пример #6
0
        public static void Update(MenuItem m_MenuItem)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "UPDATE CMS_MenuItems SET menuItemName = @menuItemName, linkUrl = @linkUrl WHERE id = @id";
            SqlCommand updateMenuItem = new SqlCommand(queryString, conn);
            updateMenuItem.Parameters.AddWithValue("menuItemName", m_MenuItem.MenuItemName);
            updateMenuItem.Parameters.AddWithValue("linkUrl", m_MenuItem.LinkUrl);
            updateMenuItem.Parameters.AddWithValue("id", m_MenuItem.Id);
            updateMenuItem.ExecuteNonQuery();

            conn.Close();
        }
Пример #7
0
        public static MenuItem RetrieveOne(int id)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "SELECT * FROM CMS_MenuItems WHERE id = @id AND pageWorkFlowState != 4";
            SqlCommand getMenuItem = new SqlCommand(queryString, conn);
            getMenuItem.Parameters.AddWithValue("id", id);
            SqlDataReader menuDateReader = getMenuItem.ExecuteReader();

            MenuItem m_MenuItem = new MenuItem();

            if (menuDateReader.Read())
            {
                m_MenuItem.Id = menuDateReader.GetInt32(0);
                m_MenuItem.ParentId = menuDateReader.GetInt32(1);
                m_MenuItem.MenuItemName = menuDateReader.GetString(2);
                m_MenuItem.LinkUrl = menuDateReader.GetString(3);
                m_MenuItem.PageWorkFlowState = menuDateReader.GetInt32(4);
                m_MenuItem.SortOrder = menuDateReader.GetInt32(5);
            }

            conn.Close();
            return m_MenuItem;
        }
 public void Update(MenuItem m_MenuItem)
 {
     DBMenuItem.Update(m_MenuItem);
 }
 public void Create(MenuItem m_MenuItem)
 {
     DBMenuItem.Create(m_MenuItem);
 }