reorg
This commit is contained in:
parent
d000f77098
commit
40e8e08690
3487 changed files with 39 additions and 21 deletions
121
src/Yavsc.Server/Models/Blog/BlogPost.cs
Normal file
121
src/Yavsc.Server/Models/Blog/BlogPost.cs
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
using Yavsc.Abstract.Identity;
|
||||
using Yavsc.Abstract.Identity.Security;
|
||||
using Yavsc.Interfaces;
|
||||
using Yavsc.Models.Access;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
namespace Yavsc.Models.Blog
|
||||
{
|
||||
public class BlogPostEditViewModel : BlogPost
|
||||
{
|
||||
public bool Publish { get; set; }
|
||||
public BlogPostEditViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public BlogPostEditViewModel(BlogPost post, bool publish)
|
||||
{
|
||||
Id = post.Id;
|
||||
AuthorId = post.AuthorId;
|
||||
Photo = post.Photo;
|
||||
Title = post.Title;
|
||||
Article = post.Article;
|
||||
Publish = publish;
|
||||
ACL = post.ACL;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class BlogPost :
|
||||
IBlogPost, ICircleAuthorized, ITaggable<long>
|
||||
{
|
||||
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
[Display(Name = "Identifiant du post")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[StringLength(1024)]
|
||||
public string? Photo { get; set; }
|
||||
|
||||
[StringLength(1024)]
|
||||
[Required]
|
||||
public string Title { get; set; }
|
||||
|
||||
[StringLength(56224)]
|
||||
public string? Article { get; set; }
|
||||
|
||||
[InverseProperty("Target")]
|
||||
[Display(Name = "Liste de contrôle d'accès")]
|
||||
public virtual List<CircleAuthorizationToBlogPost>? ACL { get; set; }
|
||||
|
||||
[Display(Name = "Identifiant de l'auteur")]
|
||||
[ForeignKey("Author")]
|
||||
public string? AuthorId { get; set; }
|
||||
|
||||
[Display(Name = "Auteur")]
|
||||
public virtual ApplicationUser? Author { set; get; }
|
||||
|
||||
|
||||
[Display(Name = "Date de création")]
|
||||
public DateTime DateCreated
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[Display(Name = "Créateur")]
|
||||
public string? UserCreated
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[Display(Name = "Dernière modification")]
|
||||
public DateTime DateModified
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[Display(Name = "Utilisateur ayant modifé le dernier")]
|
||||
public string? UserModified
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public bool AuthorizeCircle(long circleId)
|
||||
{
|
||||
return ACL?.Any(i => i.CircleId == circleId) ?? true;
|
||||
}
|
||||
|
||||
public ICircleAuthorization[] GetACL()
|
||||
{
|
||||
return ACL.ToArray();
|
||||
}
|
||||
|
||||
public void Tag(Tag tag)
|
||||
{
|
||||
var existent = Tags.SingleOrDefault(t => t.PostId == Id && t.TagId == tag.Id);
|
||||
if (existent == null) Tags.Add(new BlogTag { PostId = Id, Tag = tag });
|
||||
}
|
||||
|
||||
public void DeTag(Tag tag)
|
||||
{
|
||||
var existent = Tags.SingleOrDefault(t => ((t.TagId == tag.Id) && t.PostId == Id));
|
||||
if (existent != null) Tags.Remove(existent);
|
||||
}
|
||||
|
||||
public string[] GetTags()
|
||||
{
|
||||
return Tags.Select(t => t.Tag.Name).ToArray();
|
||||
}
|
||||
|
||||
[InverseProperty("Post")]
|
||||
public virtual List<BlogTag> Tags { get; set; }
|
||||
|
||||
[InverseProperty("Post")]
|
||||
public virtual List<Comment> Comments { get; set; }
|
||||
|
||||
IApplicationUser IBlogPost.Author { get => this.Author; }
|
||||
}
|
||||
}
|
||||
16
src/Yavsc.Server/Models/Blog/BlogTag.cs
Normal file
16
src/Yavsc.Server/Models/Blog/BlogTag.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Yavsc.Models.Relationship;
|
||||
|
||||
namespace Yavsc.Models.Blog
|
||||
{
|
||||
public partial class BlogTag
|
||||
{
|
||||
[ForeignKey("PostId")]
|
||||
public virtual BlogPost Post { get; set; }
|
||||
public long PostId { get; set; }
|
||||
|
||||
[ForeignKey("TagId")]
|
||||
public virtual Tag Tag{ get; set; }
|
||||
public long TagId { get; set; }
|
||||
}
|
||||
}
|
||||
15
src/Yavsc.Server/Models/Blog/BlogspotPublication.cs
Normal file
15
src/Yavsc.Server/Models/Blog/BlogspotPublication.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Yavsc.Models.Blog;
|
||||
|
||||
namespace Yavsc.Models
|
||||
{
|
||||
public class BlogSpotPublication
|
||||
{
|
||||
[Key]
|
||||
public long BlogpostId { get; set; }
|
||||
|
||||
[ForeignKey("BlogpostId")]
|
||||
public virtual BlogPost BlogPost{ get; set; }
|
||||
}
|
||||
}
|
||||
63
src/Yavsc.Server/Models/Blog/Comment.cs
Normal file
63
src/Yavsc.Server/Models/Blog/Comment.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
using Yavsc.Attributes.Validation;
|
||||
using Yavsc.Interfaces;
|
||||
|
||||
namespace Yavsc.Models.Blog
|
||||
{
|
||||
public class Comment : IComment<long>, ITrackedEntity
|
||||
{
|
||||
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public long Id { get; set; }
|
||||
|
||||
[YaStringLength(1024)]
|
||||
public string Article { get; set; }
|
||||
|
||||
[ForeignKeyAttribute(nameof(ReceiverId))][JsonIgnore]
|
||||
public virtual BlogPost Post { get; set; }
|
||||
|
||||
[Required]
|
||||
public long ReceiverId { get; set; }
|
||||
public bool Visible { get; set; }
|
||||
|
||||
[ForeignKeyAttribute("AuthorId")][JsonIgnore]
|
||||
public virtual ApplicationUser Author {
|
||||
get; set;
|
||||
}
|
||||
|
||||
[Required]
|
||||
public string AuthorId
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string UserCreated { get => AuthorId; set => AuthorId=value; }
|
||||
|
||||
public DateTime DateModified
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public string UserModified
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public DateTime DateCreated
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public long? ParentId { get; set; }
|
||||
|
||||
[ForeignKeyAttribute("ParentId")]
|
||||
public virtual Comment? Parent { get; set; }
|
||||
|
||||
[InversePropertyAttribute("Parent")]
|
||||
|
||||
public virtual List<Comment> Children { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue