Use new API for blog
This commit is contained in:
parent
e389b2404a
commit
25c320bf6b
17 changed files with 356 additions and 314 deletions
22
Website/Data/BlogApi.cs
Normal file
22
Website/Data/BlogApi.cs
Normal file
|
@ -0,0 +1,22 @@
|
|||
using System.Threading.Tasks;
|
||||
using Website.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace Website.Data
|
||||
{
|
||||
public class BlogApi : ApiClient, IBlogApi {
|
||||
public BlogApi(HttpClient client) : base(client) {
|
||||
}
|
||||
|
||||
public async Task<BlogPost> GetPostByUrlAsync(string url) => await Get<BlogPost>("/get/" + url);
|
||||
public async Task<IEnumerable<BlogPost>> GetLatestPostsAsync(int count = 0, int offset = 0) => await Get<IEnumerable<BlogPost>>("/getlatestposts", new{count, offset});
|
||||
public async Task<BlogPost> GetLatestPostAsync() => await Get<BlogPost>("/getlatestpost");
|
||||
public async Task<int> GetCountAsync() => await Get<int>("/getcount");
|
||||
public async Task<BlogPost> GetPostByIdAsync(int id) => await Get<BlogPost>("/get/" + id);
|
||||
public async Task<BlogPost> SavePost(BlogPostSubmission post) => await Post<BlogPost>("/savepost", post);
|
||||
public async Task<IEnumerable<BlogPost>> GetAllPostsAsync() => await Get<IEnumerable<BlogPost>>("/getallposts");
|
||||
public async Task DeletePostAsync(int id) => await Post<object>("/deletepost", id);
|
||||
public async Task PublishPostAsync(int id) => await Post<object>("/publishpost", id);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue