Exemplo n.º 1
0
        public static List<Menu> RetrieveAll()
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "SELECT * FROM CMS_Menus WHERE pageWorkFlowState != 4";
            SqlCommand getMenus = new SqlCommand(queryString, conn);
            SqlDataReader menuDataReader = getMenus.ExecuteReader();

            List<Menu> m_Menus = new List<Menu>();

            while (menuDataReader.Read())
            {
                Menu tempMenu = new Menu();

                tempMenu.Id = menuDataReader.GetInt32(0);
                tempMenu.MenuName = menuDataReader.GetString(1);
                tempMenu.PageWorkFlowState = menuDataReader.GetInt32(2);

                m_Menus.Add(tempMenu);
            }

            conn.Close();
            return m_Menus;
        }
Exemplo n.º 2
0
 public ActionResult AddMenu(Menu m_Menu)
 {
     if (ModelState.IsValid)
     {
         MenuRepository.Create(m_Menu);
         return RedirectToAction("Index", "Menu");
     }
     else
     {
         return View("AddMenu", m_Menu);
     }
 }
Exemplo n.º 3
0
        public static void Create(Menu m_Menu)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "INSERT INTO CMS_Menus(menuName, pageWorkFlowState) VALUES(@menuName, 0)";
            SqlCommand insertMenu = new SqlCommand(queryString, conn);
            insertMenu.Parameters.AddWithValue("menuName", m_Menu.MenuName);
            insertMenu.ExecuteNonQuery();

            conn.Close();
        }
Exemplo n.º 4
0
 public ActionResult AddMenu()
 {
     Menu m_Menu = new Menu();
     return View("AddMenu", m_Menu);
 }
Exemplo n.º 5
0
        public static Menu RetrieveOne(int id)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

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

            Menu m_Menu = new Menu();

            if(menuDataReader.Read())
            {
                m_Menu.Id = menuDataReader.GetInt32(0);
                m_Menu.MenuName = menuDataReader.GetString(1);
                m_Menu.PageWorkFlowState = menuDataReader.GetInt32(2);
            }

            conn.Close();
            return m_Menu;
        }
Exemplo n.º 6
0
        public static void Update(Menu m_Menu)
        {
            SqlConnection conn = DB.DbConnect();
            conn.Open();

            string queryString = "UPDATE CMS_Menus SET menuName = @menuName WHERE id = @id";
            SqlCommand updateMenu = new SqlCommand(queryString, conn);
            updateMenu.Parameters.AddWithValue("menuName", m_Menu.MenuName);
            updateMenu.Parameters.AddWithValue("id", m_Menu.Id);
            updateMenu.ExecuteNonQuery();

            conn.Close();
        }
Exemplo n.º 7
0
 public void Update(Menu m_Menu)
 {
     DBMenu.Update(m_Menu);
 }
Exemplo n.º 8
0
 public void Create(Menu m_Menu)
 {
     DBMenu.Create(m_Menu);
 }