public void AddWedget(enable_wedget mst) { try { using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { string check = @"SELECT count(*) FROM enable_wedget where user_id = @user_id and wedget_id = @wedget_id"; int cnt = con.Query <int>(check, new { user_id = mst.user_id, wedget_id = mst.wedget_id }).SingleOrDefault(); if (cnt == 0) { string query = @"INSERT INTO enable_wedget (user_id, wedget_id) VALUES (@user_id, @wedget_id);"; con.Execute(query, new { mst.user_id, mst.wedget_id }); } } } catch (Exception ex) { throw ex; } }
public void DeleteWedget(enable_wedget mst) { try { using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString())) { string query = @"DELETE FROM enable_wedget WHERE user_id = @user_id AND wedget_id = @wedget_id;"; con.Execute(query, new { mst.user_id, mst.wedget_id }); } } catch (Exception ex) { throw ex; } }