Exemplo n.º 1
0
        public async Task <IActionResult> OnPostCreateAsync()
        {
            string token = await idData.GetAccessToken(HttpContext);

            try
            {
                PostData.Data.Keywords = PostData.EditKeywords?.Split(';');
                int?id = await client.Create(token, PostData.Data);

                return(RedirectToPage(new { id }));
            }
            catch
            {
                return(NotFound());
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> OnPostInitializeAsync()
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(Unauthorized());
            }

            string token = await idData.GetAccessToken(HttpContext);

            List <Category> tags = new List <Category>();

            for (int i = 1; i <= 5; i++)
            {
                Category t = new Category {
                    Name = $"category{i}", Color = RandomHelper.Color()
                };
                t.Id = (await tagsClient.Create(token, t)).Value;
                tags.Add(t);
            }

            List <Note> nodes = new List <Note>();

            for (int i = 1; i <= 10; i++)
            {
                Note t = new Note {
                    Title = $"Note {i}", Content = $"Contents of note {i}.", CategoryId = RandomHelper.Choice(tags).Id
                };
                t.Id = (await nodesClient.Create(token, t)).Value;
                nodes.Add(t);
            }

            List <Relation> relations = new List <Relation>();

            for (int i = 1; i <= 10; i++)
            {
                Relation t = new Relation {
                    From = RandomHelper.Choice(nodes).Id, To = RandomHelper.Choice(nodes).Id
                };
                t.Id = (await relationsClient.Create(token, t)).Value;
                relations.Add(t);
            }

            return(RedirectToPage());
        }