コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }