yavsc/Yavsc/Models/Blog/Blog.cs

78 lines
2 KiB
C#
Raw Normal View History

2016-05-17 18:22:18 +02:00
using System;
2017-01-20 14:20:44 +01:00
using System.Collections.Generic;
2016-05-17 18:22:18 +02:00
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
2016-08-03 23:25:57 +02:00
using Newtonsoft.Json;
2017-01-20 14:20:44 +01:00
using Yavsc.Models.Access;
2016-05-17 18:22:18 +02:00
namespace Yavsc.Models
{
public partial class Blog : IBlog, ICircleAuthorized
2016-05-17 18:22:18 +02:00
{
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
2017-03-10 16:42:57 +01:00
[Display(Name="Identifiant du post")]
2016-05-17 18:22:18 +02:00
public long Id { get; set; }
2016-07-27 10:55:44 +02:00
2017-03-10 16:42:57 +01:00
[Display(Name="Contenu")]
2016-08-02 17:02:38 +02:00
public string Content { get; set; }
2017-03-10 16:42:57 +01:00
[Display(Name="Photo")]
2016-08-02 17:02:38 +02:00
public string Photo { get; set; }
2017-03-10 16:42:57 +01:00
[Display(Name="Indice de qualité")]
2016-08-02 17:02:38 +02:00
public int Rate { get; set; }
2017-03-10 16:42:57 +01:00
[Display(Name="Titre")]
2016-08-02 17:02:38 +02:00
public string Title { get; set; }
2017-03-10 16:42:57 +01:00
[Display(Name="Identifiant de l'auteur")]
2016-05-17 18:22:18 +02:00
public string AuthorId { get; set; }
2017-03-10 16:42:57 +01:00
[Display(Name="Auteur")]
2017-05-27 16:22:58 +02:00
2016-08-03 23:25:57 +02:00
[ForeignKey("AuthorId"),JsonIgnore]
2016-07-27 10:55:44 +02:00
public ApplicationUser Author { set; get; }
2017-03-10 16:42:57 +01:00
[Display(Name="Visible")]
2016-08-02 17:02:38 +02:00
public bool Visible { get; set; }
2017-01-17 14:56:53 +01:00
2017-03-10 16:42:57 +01:00
[Display(Name="Date de création")]
2017-01-17 14:56:53 +01:00
public DateTime DateCreated
{
get; set;
}
2017-03-10 16:42:57 +01:00
[Display(Name="Créateur")]
2017-01-17 14:56:53 +01:00
public string UserCreated
{
get; set;
}
2017-03-10 16:42:57 +01:00
[Display(Name="Dernière modification")]
2017-01-17 14:56:53 +01:00
public DateTime DateModified
{
get; set;
}
2017-03-10 16:42:57 +01:00
[Display(Name="Utilisateur ayant modifé le dernier")]
2017-01-17 14:56:53 +01:00
public string UserModified
{
get; set;
}
2017-05-27 16:22:58 +02:00
[InverseProperty("Target")]
2017-03-10 16:42:57 +01:00
[Display(Name="Liste de contrôle d'accès")]
2017-01-20 14:20:44 +01:00
public virtual List<CircleAuthorizationToBlogPost> ACL { get; set; }
public bool AuthorizeCircle(long circleId)
{
2017-05-27 18:29:45 +02:00
return ACL?.Any( i=>i.CircleId == circleId) ?? true;
}
public string GetOwnerId()
{
return AuthorId;
}
public ICircleAuthorization[] GetACL()
{
return ACL.ToArray();
}
2016-05-17 18:22:18 +02:00
}
}