public int DeleteLikedSublet(LikedSublets ls) { SqlConnection con; try { con = connect("ConnectionStringName"); // create the connection } catch (Exception ex) { // write to log throw (ex); } String selectSTR = "DELETE FROM LikedSubletsTbl WHERE UserFBID = '" + ls.UserFBID + "' AND SubletID = " + ls.SubletID + ";"; SqlCommand cmd = new SqlCommand(selectSTR, con); // create the command try { int numEffected = cmd.ExecuteNonQuery(); // execute the command return(numEffected); } catch (Exception ex) { return(0); // write to log throw (ex); } finally { if (con != null) { // close the db connection con.Close(); } } }
// DELETE api/<controller>/5 public void Delete([FromBody] LikedSublets ls) { LikedSublets l = new LikedSublets(); l.DeleteLikedSublet(ls); }
// POST api/<controller> public void Post([FromBody] LikedSublets[] ls) { LikedSublets l = new LikedSublets(); l.UpdateLikedSublets(ls); }