Example #1
0
        private async Task <bool> GetData(int id, string token)
        {
            try
            {
                Data = new NotesViewModel {
                    Data = await client.Get(token, id)
                };
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            string token = await idData.GetAccessToken(HttpContext);

            try
            {
                Data = new NotesViewModel {
                    Data = await client.Get(token, id)
                };
                Markdown = new MarkdownViewModel {
                    Raw = Data.Data.Content
                };
                await Data.Load(tagsClient, usersClient, token);

                /*
                 * List<Relation> res = (await relationsClient.GetAdjacents(token, id)).ToList();
                 * if (res.Count > 0)
                 * {
                 *  RelationHelper.D3Graph graph = await RelationHelper.GenerateGraph(client, tagsClient, res, token);
                 *  Graph = new GraphViewModel
                 *  {
                 *      Graph = graph,
                 *      SelectNodeIndex = graph.nodes.IndexOf(graph.nodes.First(x => x.id == id)),
                 *  };
                 * }
                 * else
                 * {
                 *  RelationHelper.D3Graph graph = await RelationHelper.GenerateGraph(client, tagsClient, res, token, new Note[] { Data.Data });
                 *  Graph = new GraphViewModel
                 *  {
                 *      Graph = graph,
                 *      SelectNodeIndex = 0,
                 *  };
                 * }
                 */
            }
            catch
            {
                return(NotFound());
            }

            return(Page());
        }
Example #3
0
        public static async Task <IEnumerable <Note> > GetNotes(INotesClient client, IEnumerable <Relation> relations, string token)
        {
            if (relations == null)
            {
                return(Array.Empty <Note>());
            }

            HashSet <int> ns = new HashSet <int>();

            foreach (Relation v in relations)
            {
                ns.Add(v.From);
                ns.Add(v.To);
            }
            List <Note> res = new List <Note>();

            foreach (int v in ns)
            {
                res.Add(await client.Get(token, v));
            }
            return(res);
        }