/// <summary> /// Retrieves a single Note Record from the database /// </summary> /// <param name="id">Note identifier</param> public async Task <Note> GetNote(int id) { Note noteRecord = null; using (var conn = GetConnection()) { conn.Open(); var cmd = new MySqlCommand("SELECT * FROM note WHERE NoteId = @noteId", conn); cmd.Parameters.AddWithValue("@noteId", id); using (var reader = await cmd.ExecuteReaderAsync()) { while (reader.Read()) { noteRecord = new Note() { NoteId = Convert.ToUInt32(reader["NoteId"]), CategoryId = Convert.ToUInt32(reader["CategoryId"]), NoteClassification = (NoteClassification)Convert.ToUInt32(reader["NoteClassification"]), NoteTitle = reader["NoteTitle"].ToString(), APP_GUID = reader["APP_GUID"].ToString(), NoteContent = reader["NoteContent"].ToString(), NoteCoordinates = await BasicCoordinatesDBContext.GetGeoposition(Convert.ToUInt32(reader["NoteId"]), Common.CoordinatesParentType.Note), NoteDatetime = ConversionHelpers.SafeGetDateTime(reader, reader.GetOrdinal("NoteDatetime")), CreatedAt = Convert.ToDateTime(reader["CreatedAt"]), CreatedBy = Convert.ToUInt32(reader["CreatedBy"]), ModifiedAt = ConversionHelpers.SafeGetDateTime(reader, reader.GetOrdinal("ModifiedAt")), ModifiedBy = ConversionHelpers.SafeGetInt(reader, reader.GetOrdinal("ModifiedBy")), }; } } } return(noteRecord); }
public NoteDBContext(string connectionString) { ConnectionString = connectionString; BasicCoordinatesDBContext = new BasicCoordinatesDBContext(); }