public string UpdateApi(string apiId, ApiDM apiDm) { string _returnedMsg = ""; try { using (SqlConnection conn = GetConnection()) { conn.Open(); SqlCommand cmd = new SqlCommand("UPDATE tApi SET fApiDesc = @ApiDesc WHERE fApiId = @ApiId", conn); cmd.Parameters.AddWithValue("@ApiId", apiId); cmd.Parameters.AddWithValue("@ApiDesc", apiDm.ApiDesc); cmd.ExecuteNonQuery(); conn.Close(); _returnedMsg = "API Successfully Updated"; } } catch (Exception e) { _returnedMsg = "Operation Failed!"; } return(_returnedMsg); }
public string CreateApi(ApiDM apiDm) { string _returnedMsg = ""; try { using (SqlConnection conn = GetConnection()) { conn.Open(); SqlCommand cmd = new SqlCommand("INSERT INTO tApi(fApiId, fApiDesc) VALUES (@ApiId, @ApiDesc)", conn); cmd.Parameters.AddWithValue("@ApiId", apiDm.ApiId); cmd.Parameters.AddWithValue("@ApiDesc", apiDm.ApiDesc); cmd.ExecuteNonQuery(); conn.Close(); } _returnedMsg = "API Successfully Added"; } catch (Exception e) { _returnedMsg = "Operation Failed!"; } return(_returnedMsg); }