public bool Create(TopicMessageDTO note) { try { return(dal.Create(note)); } catch (Exception e) { Logger.Logger.WriteLog(e); throw e; } }
public bool Create(TopicMessageDTO note) { using (var connection = new SqlConnection(connectionString)) { var add_topic_message = connection.CreateCommand(); add_topic_message.CommandText = $"INSERT INTO dbo.TopicMessage (MessageId, TopicId) VALUES (@MessageId, @TopicId)"; add_topic_message.Parameters.AddWithValue("@MessageId", note.MessageId); add_topic_message.Parameters.AddWithValue("@TopicId", note.TopicId); connection.Open(); var result = add_topic_message.ExecuteNonQuery(); return(result > 0); } }
public bool Update(TopicMessageDTO note) { try { dal.Update(note); return(true); } catch (Exception e) { Logger.Logger.WriteLog(e); throw e; } }
public bool Update(TopicMessageDTO note) { using (var connection = new SqlConnection(connectionString)) { var update_topic_message = connection.CreateCommand(); update_topic_message.CommandText = $"UPDATE dbo.TopicMessage SET MessageId = @MessageId, TopicId = @TopicId WHERE Id = @Id"; update_topic_message.Parameters.AddWithValue("@Id", note.Id); update_topic_message.Parameters.AddWithValue("@MessageId", note.MessageId); update_topic_message.Parameters.AddWithValue("@TopicId", note.TopicId); connection.Open(); var result = update_topic_message.ExecuteNonQuery(); return(result > 0); } }