Ejemplo n.º 1
0
        public IQueryable <Note> GetAttachedNotes(IRdbDataEntity attachmentSite)
        {
            try
            {
                int pk  = Convert.ToInt32(((IPrimaryKey)attachmentSite).Key);
                var tid = GetTableObjectId(attachmentSite);

                return
                    ((
                         from nt in this.NoteTargets
                         where nt.TableObjectId == tid && nt.TablePkIntVal == pk
                         select nt.Note
                         ).Include(n => n.CreatedByContact));
            }
            catch (Exception)
            {
                return(Note.None.ToList().AsQueryable());
            }
        }
Ejemplo n.º 2
0
        SerializableTreeNode <Note> INoteService.GetNoteNodes(IRdbDataEntity entityWithAttachedNotes)
        {
            var notes = Rdb.GetAttachedNotes(entityWithAttachedNotes).Include(z => z.CreatedByContact);
            var root  = new SerializableTreeNode <Note>(null);

            foreach (var note in notes)
            {
                var currentNoteNode = new SerializableTreeNode <Note>(note);
                if (note.ParentNoteId != null)
                {
                    SerializableTreeNode <Note> parentNoteNode = null;

                    //find parent in root and add child to it
                    root.Walk((node, depth) =>
                    {
                        if (node.Data?.NoteId == note.ParentNoteId)
                        {
                            node.Add(currentNoteNode);
                            parentNoteNode = node;
                            return;
                        }
                    });

                    //parent isn't in root
                    if (parentNoteNode == null)
                    {
                        var parentNote = notes.SingleOrDefault(x => x.NoteId == note.ParentNoteId);
                        parentNoteNode = new SerializableTreeNode <Note>(parentNote);
                        parentNoteNode?.Add(currentNoteNode);
                    }
                }
                else
                {
                    root.Add(currentNoteNode);
                }
            }

            root.Children = root.Children.OrderBy(x => x.Data.CreatedAtUtc).ToList();
            return(root);
        }
Ejemplo n.º 3
0
        protected IQueryable <Note> GetNotes(IRdbDataEntity entityWithAttachedNotes)
        {
            var notes = Rdb.GetAttachedNotes(entityWithAttachedNotes).Include(z => z.CreatedByContact);

            return(notes);
        }
Ejemplo n.º 4
0
 public async Task <IActionResult> CreateNote(
     int?parentNoteId,
     string content,
     IRdbDataEntity attachmentSite) => await CreateNote(parentNoteId, content, new[] { attachmentSite });
Ejemplo n.º 5
0
 private int GetTableObjectId(IRdbDataEntity e)
 => GetDatabaseObjectId(AttributeStuff.GetCustomAttribute <TableAttribute>(e.GetType()));