Пример #1
0
        public bool UpdateMenuItemRow(MenuItemModel model)
        {
            bool success = false;

            conn.Open();
            using (IDbTransaction trans = conn.BeginTransaction())
            {
                string sql = @"UPDATE `halifaxdine`.`menu_item`
                                  SET
                                  `MENU_PRICE` = @Menu_Price,
                                  `MENU_DESC` = @Menu_Desc,
                                  `MENU_NAME` = @Menu_Name
                                  WHERE `MENU_ID` = @Menu_Id
                                  ";

                try
                {
                    success = 1 == conn.Execute(sql, new { model.Menu_Id, model.Menu_Price, model.Menu_Name, model.Menu_Desc });
                    trans.Commit();
                }
                catch (Exception e)
                {
                    trans.Rollback();
                }
            }
            conn.Close();

            return(success);
        }
Пример #2
0
        public bool DeleteMenuItemRow(MenuItemModel model)
        {
            bool success = false;

            conn.Open();
            using (IDbTransaction trans = conn.BeginTransaction())
            {
                string sql = @"delete from `halifaxdine`.`menu_item`
                                  WHERE `MENU_ID` = @Menu_Id
                                  ";

                try
                {
                    success = 1 == conn.Execute(sql, new { model.Menu_Id });
                    trans.Commit();
                }
                catch (Exception e)
                {
                    trans.Rollback();
                }
            }
            conn.Close();

            return(success);
        }
Пример #3
0
        public bool InsertMenuItemRow(MenuItemModel model)
        {
            bool success = false;

            conn.Open();
            using (IDbTransaction trans = conn.BeginTransaction())
            {
                string sql = @"INSERT INTO `halifaxdine`.`menu_item`
                                (`MENU_ID`,
                                `MENU_PRICE`,
                                `MENU_DESC`,
                                `MENU_NAME`)
                                VALUES
                                (Default,
                                @Menu_Price,
                                @Menu_Desc,
                                @Menu_Name)";

                try
                {
                    success = 1 == conn.Execute(sql, new { model.Menu_Price, model.Menu_Name, model.Menu_Desc });
                    trans.Commit();
                }
                catch (Exception e)
                {
                    trans.Rollback();
                }
            }
            conn.Close();

            return(success);
        }