public Note SelectNote(Note note) { try { using (SqlConnection conn = DbHelpper.GetConnection()) { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@id", note.Id); Note result = conn.Query <Note>("SelectId", parameters, commandType: CommandType.StoredProcedure).FirstOrDefault(); return(result); } } catch (Exception ex) { Console.WriteLine(ex.Message); return(null); } }
public int DeleteNote(Note note) { try { using (SqlConnection conn = DbHelpper.GetConnection()) { DynamicParameters parameters = new DynamicParameters(); parameters.Add("@id", note.Id); int result = conn.Execute("DeleteNote", parameters, commandType: CommandType.StoredProcedure); return(result); } } catch (Exception ex) { Console.WriteLine(ex.Message); return(-1); } }