Ejemplo n.º 1
0
        protected override async Task OnInitializedAsync()
        {
            List <BlogPosts> blogs = await BlogService.GetBlogsAsync();

            thisblog = blogs.FirstOrDefault(x => x.Slug == Slug && x.Published);
            if (thisblog != null)
            {
                thisblogsingle = await BlogService.GetBlogPostAsync(thisblog.Id);
            }

            this.StateHasChanged();
        }
Ejemplo n.º 2
0
        public async Task <BlogPostsSingle> GetBlogPostAsync(int id)
        {
            var call = Client.GetAsync(new Uri(Client.BaseAddress + "articles/" + id.ToString()));
            HttpResponseMessage httpResponse = await call;

            string result = await httpResponse.Content.ReadAsStringAsync();

            BlogPostsSingle post = JsonConvert.DeserializeObject <BlogPostsSingle>(result);

            httpResponse.Dispose();

            return(post);
        }