public async Task <Note> GetNoteByIdAsync(int noteId) { try { Casenotes dbNote = await _context.Casenotes.FirstOrDefaultAsync(n => n.Noteid == noteId); if (dbNote == null) { return(null); } return(CaseNoteMapper.Map(dbNote)); } catch (Exception e) { return(null); } }
public async Task <bool> AddNoteToCaseAsync(Case targetCase, Note note, bool save = true) { try { // First, add the note note.CaseId = targetCase.Id; _context.Casenotes.Add(CaseNoteMapper.Map(note)); // Finally, update the case model and db targetCase.Notes.Add(note); if (save) { await _context.SaveChangesAsync(); } return(true); } catch (Exception e) { return(false); } }