fixies the refact of blog spot index
All checks were successful
Dotnet build and test / log-the-inputs (push) Successful in 5s
Dotnet build and test / build (push) Successful in 1m58s

This commit is contained in:
Paul Schneider
2025-06-29 19:53:56 +01:00
parent fdf75934e5
commit 3f1bfc1c3c
13 changed files with 46 additions and 31 deletions

View File

@ -1,6 +1,8 @@
 
using Yavsc.Abstract.Identity;
namespace Yavsc namespace Yavsc
{ {
public interface IBlogPostPayLoad public interface IBlogPostPayLoad
@ -12,5 +14,6 @@ namespace Yavsc
public interface IBlogPost : IBlogPostPayLoad, ITrackedEntity, IIdentified<long>, ITitle public interface IBlogPost : IBlogPostPayLoad, ITrackedEntity, IIdentified<long>, ITitle
{ {
string AuthorId { get; set; } string AuthorId { get; set; }
IApplicationUser Author { get; }
} }
} }

View File

@ -54,7 +54,7 @@ namespace Yavsc.Models.Google.Messaging
/// <summary> /// <summary>
/// The error. /// The error.
/// </summary> /// </summary>
public string error; public string? error;
} }
/// <summary> /// <summary>

View File

@ -3,10 +3,10 @@
public interface IApplicationUser public interface IApplicationUser
{ {
string Id { get; set; } string Id { get; set; }
string UserName { get; set; } string? UserName { get; set; }
string Avatar { get ; set; } string? Avatar { get ; set; }
IAccountBalance AccountBalance { get; set; } IAccountBalance? AccountBalance { get; }
string DedicatedGoogleCalendar { get; set; } string? DedicatedGoogleCalendar { get; }
ILocation PostalAddress { get; set; } ILocation? PostalAddress { get; }
} }
} }

View File

@ -3,7 +3,7 @@ namespace Yavsc.Abstract.Identity.Security
public interface ICircleAuthorized public interface ICircleAuthorized
{ {
long Id { get; set; } long Id { get; set; }
string OwnerId { get; } string AuthorId { get; }
bool AuthorizeCircle(long circleId); bool AuthorizeCircle(long circleId);
ICircleAuthorization [] GetACL(); ICircleAuthorization [] GetACL();

View File

@ -7,10 +7,12 @@ using Yavsc.Models.Identity;
using Yavsc.Models.Chat; using Yavsc.Models.Chat;
using Yavsc.Models.Bank; using Yavsc.Models.Bank;
using Yavsc.Models.Access; using Yavsc.Models.Access;
using Yavsc.Abstract.Identity;
namespace Yavsc.Models namespace Yavsc.Models
{ {
[Table("AspNetUsers")] [Table("AspNetUsers")]
public class ApplicationUser : IdentityUser public class ApplicationUser : IdentityUser, IApplicationUser
{ {
/// <summary> /// <summary>
/// Another me, as a byte array.TG7@Eu%80rufzkhbb /// Another me, as a byte array.TG7@Eu%80rufzkhbb
@ -22,10 +24,10 @@ namespace Yavsc.Models
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[MaxLength(512)] [MaxLength(512)]
public string Avatar { get; set; } public string? Avatar { get; set; }
[MaxLength(512)] [MaxLength(512)]
public string FullName { get; set; } public string? FullName { get; set; }
/// <summary> /// <summary>
@ -33,7 +35,7 @@ namespace Yavsc.Models
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[Display(Name = "Account balance")] [Display(Name = "Account balance")]
public virtual AccountBalance AccountBalance { get; set; } public virtual AccountBalance? AccountBalance { get; set; }
/// <summary> /// <summary>
/// User's posts /// User's posts
@ -113,5 +115,8 @@ namespace Yavsc.Models
[InverseProperty("Member")] [InverseProperty("Member")]
public virtual List<CircleMember> Membership { get; set; } public virtual List<CircleMember> Membership { get; set; }
IAccountBalance? IApplicationUser.AccountBalance => AccountBalance;
ILocation? IApplicationUser.PostalAddress { get => PostalAddress; }
} }
} }

View File

@ -5,6 +5,8 @@ using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json; using Newtonsoft.Json;
using Yavsc;
using Yavsc.Abstract.Identity;
using Yavsc.Abstract.Identity.Security; using Yavsc.Abstract.Identity.Security;
using Yavsc.Attributes.Validation; using Yavsc.Attributes.Validation;
using Yavsc.Interfaces; using Yavsc.Interfaces;
@ -86,7 +88,6 @@ namespace Yavsc.Models.Blog
[InverseProperty("Post")] [InverseProperty("Post")]
public virtual List<Comment> Comments { get; set; } public virtual List<Comment> Comments { get; set; }
[NotMapped] IApplicationUser IBlogPost.Author { get => this.Author; }
public string OwnerId => AuthorId;
} }
} }

View File

@ -8,10 +8,10 @@ namespace Yavsc.Models.societe.com
public class CompanyInfoMessage public class CompanyInfoMessage
{ {
public bool success { get; set; } public bool success { get; set; }
public string errorType { get; set; } public string? errorType { get; set; }
public string errorCode { get; set; } public string? errorCode { get; set; }
public string errorMessage { get; set; } public string? errorMessage { get; set; }
public CompanyInfo result { get; set; } public CompanyInfo? result { get; set; }
} }

View File

@ -47,7 +47,7 @@ namespace Yavsc.Controllers
await blogSpotService.UserPosts(id, User.GetUserId(), await blogSpotService.UserPosts(id, User.GetUserId(),
skip, take)); skip, take));
} }
var byTitle = await this.blogSpotService.IndexByTitle(User, id, skip, take); IEnumerable<IGrouping<string,IBlogPost>> byTitle = await this.blogSpotService.IndexByTitle(User, id, skip, take);
return View(byTitle); return View(byTitle);
} }

View File

@ -85,7 +85,7 @@ public class PermissionHandler : IAuthorizationHandler
{ {
return applicationDbContext.CircleMembers return applicationDbContext.CircleMembers
.Include(c => c.Circle) .Include(c => c.Circle)
.Where(m=>m.MemberId==user.GetUserId() && m.Circle.OwnerId == blogPost.OwnerId) .Where(m=>m.MemberId==user.GetUserId() && m.Circle.OwnerId == blogPost.AuthorId)
.Any(); .Any();
} }
return true; return true;

View File

@ -22,7 +22,7 @@ namespace Yavsc.ViewComponents
{ {
if (target!=null) if (target!=null)
{ {
var oid = target.OwnerId; var oid = target.AuthorId;
ViewBag.ACL = dbContext.Circle.Where( ViewBag.ACL = dbContext.Circle.Where(
c=>c.OwnerId == oid) c=>c.OwnerId == oid)
.Select( .Select(

View File

@ -1,4 +1,4 @@
@model IEnumerable<IGrouping<string,BlogPost>> @model IEnumerable<IGrouping<string,IBlogPost>>
@{ @{
ViewData["Title"] = "Blogs, l'index"; ViewData["Title"] = "Blogs, l'index";
} }

View File

@ -1,14 +1,10 @@
@using Yavsc.Abstract.Identity
@model ApplicationUser @model ApplicationUser
@{ @{
var avuri = "/Avatars/" + Model.UserName + ".s.png"; var avuri = "/Avatars/" + Model.UserName + ".s.png";
var userPosted = Model.Posts!=null && Model.Posts.Count()>=1;
} }
<div class="userinfo"> <div class="userinfo">
@if (userPosted) { <a asp-controller="Blogspot" asp-action="Index" <a title="Posts" asp-controller="Blogspot" asp-action="Index" asp-route-id="@Model.UserName" class="btn btn-primary">
asp-route-id="@Model.UserName" class="btn btn-primary">
<img src="@avuri" asp-append-version="true" class="smalltofhol" alt="@Model.UserName" title="@Model.UserName" /> <img src="@avuri" asp-append-version="true" class="smalltofhol" alt="@Model.UserName" title="@Model.UserName" />
</a> </a>
} else {
Html.DisplayFor(m=>m.UserName);
}
</div> </div>

View File

@ -0,0 +1,10 @@
@using Yavsc.Abstract.Identity
@model IApplicationUser
@{
var avuri = "/Avatars/" + Model.UserName + ".s.png";
}
<div class="userinfo">
<a title="Posts" asp-controller="Blogspot" asp-action="Index" asp-route-id="@Model.UserName" class="btn btn-primary">
<img src="@avuri" asp-append-version="true" class="smalltofhol" alt="@Model.UserName" title="@Model.UserName" />
</a>
</div>