refacto BlogPost serialization
This commit is contained in:
parent
ff7a6ac16d
commit
64547840e4
8 changed files with 22 additions and 17 deletions
|
|
@ -7,9 +7,8 @@ using Yavsc.Interfaces;
|
|||
|
||||
namespace Yavsc.Blogspot
|
||||
{
|
||||
public interface IBlogPost : IBlogPostPayLoad, ICircleAuthorized, ITaggable<long>, ITrackedEntity, IIdentified<long>, ITitle
|
||||
public interface IBlogPost : IBlogPostPayLoad, ICircleAuthorized, ITrackedEntity, ITitle
|
||||
{
|
||||
string AuthorId { get; set; }
|
||||
IApplicationUser Author { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
using Yavsc.Interfaces;
|
||||
|
||||
namespace Yavsc.Abstract.Identity.Security
|
||||
{
|
||||
public interface ICircleAuthorized
|
||||
public interface ICircleAuthorized : ITaggable<long>
|
||||
{
|
||||
long Id { get; set; }
|
||||
|
||||
string AuthorId { get; }
|
||||
|
||||
bool AuthorizeCircle(long circleId);
|
||||
|
||||
ICircleAuthorization [] GetACL();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
namespace Yavsc.Interfaces
|
||||
{
|
||||
public interface ITaggable<K>
|
||||
public interface ITaggable<K> : IIdentified<K>
|
||||
{
|
||||
string [] GetTags();
|
||||
|
||||
|
|
|
|||
|
|
@ -239,7 +239,8 @@ public sealed class BlogApiTests : IClassFixture<BlogsWebServerFixture>
|
|||
|
||||
// The list should now be empty.
|
||||
var listResponse = await http.GetAsync("/api/v1/blog");
|
||||
using var doc = JsonDocument.Parse(await listResponse.Content.ReadAsStringAsync());
|
||||
String response = await listResponse.Content.ReadAsStringAsync();
|
||||
using var doc = JsonDocument.Parse(response);
|
||||
Assert.Equal(0, doc.RootElement.GetArrayLength());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@ namespace Yavsc.Blogs.Controllers
|
|||
|
||||
// GET: api/BlogApi
|
||||
[HttpGet]
|
||||
public async Task<IEnumerable<IBlogPost>> GetBlogspot(int start = 0, int take = 25)
|
||||
public async Task<IEnumerable<BlogPost>> GetBlogspot(int start = 0, int take = 25)
|
||||
{
|
||||
return await blogSpotService.Index(User, null, start, take);
|
||||
return (await blogSpotService.Index(User, null, start, take)).Cast<BlogPost>();
|
||||
}
|
||||
|
||||
// GET: api/BlogApi/5
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"Site": {
|
||||
"Authority": "https://localhost:5101",
|
||||
"Audience": ["blogs"],
|
||||
"Title": "Yavsc dev",
|
||||
"Slogan": "Yavsc : WIP.",
|
||||
"Banner": "/images/yavsc.png",
|
||||
|
|
|
|||
|
|
@ -52,19 +52,19 @@
|
|||
<div class="post card">
|
||||
|
||||
|
||||
<a asp-action="Details" asp-route-id="@((IBlogPost)post).Id" class="bloglink" >
|
||||
<a asp-action="Details" asp-route-id="@post.Id" class="bloglink" >
|
||||
<div class="float-left"><img class="photo card-photo" src="@post.Photo" ></div>
|
||||
<h3 class="index-post-title">@post.Title</h3>
|
||||
</a>
|
||||
<div>
|
||||
<a asp-action="Details" asp-route-id="@((IBlogPost)post).Id">
|
||||
<a asp-action="Details" asp-route-id="@post.Id">
|
||||
<asciidoc summary="@maxTextLen">@post.Article</asciidoc></a>
|
||||
<span style="font-size:x-small;">@Html.DisplayFor(m => post.Author)</span>
|
||||
<span style="font-size:xx-small;">
|
||||
posté le @post.DateCreated.ToString("dddd d MMM yyyy à H:mm")
|
||||
@if ((post.DateModified - post.DateCreated).Minutes > 0){
|
||||
@:- Modifié le @post.DateModified.ToString("dddd d MMM yyyy à H:mm")
|
||||
})
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
<div class="actiongroup">
|
||||
|
|
@ -74,13 +74,13 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
<a asp-action="Details" asp-route-id="@((IBlogPost)post).Id" class="btn btn-light">Details</a>
|
||||
<a asp-action="Details" asp-route-id="@post.Id" class="btn btn-light">Details</a>
|
||||
}
|
||||
@if ((await AuthorizationService.AuthorizeAsync(User, post, new EditPermission())).Succeeded)
|
||||
{
|
||||
<a asp-action="Edit" asp-route-id="@((IBlogPost)post).Id" class="btn btn-primary">Edit</a>
|
||||
<a asp-action="Edit" asp-route-id="@post.Id" class="btn btn-primary">Edit</a>
|
||||
|
||||
<a asp-action="Delete" asp-route-id="@((IBlogPost)post).Id" class="btn btn-danger">Delete</a>
|
||||
<a asp-action="Delete" asp-route-id="@post.Id" class="btn btn-danger">Delete</a>
|
||||
|
||||
}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace Yavsc.Models.Blog
|
|||
public string? AuthorId { get; set; }
|
||||
|
||||
[Display(Name = "Auteur")]
|
||||
public virtual ApplicationUser? Author { set; get; }
|
||||
public virtual ApplicationUser Author { set; get; }
|
||||
|
||||
|
||||
[Display(Name = "Date de création")]
|
||||
|
|
@ -95,6 +95,6 @@ namespace Yavsc.Models.Blog
|
|||
[InverseProperty("Post")]
|
||||
public virtual List<Comment> Comments { get; set; }
|
||||
|
||||
IApplicationUser IBlogPost.Author { get => this.Author; }
|
||||
IApplicationUser IBlogPost.Author => Author;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue