Ajoute ou supprime des cercle aux posts

This commit is contained in:
Paul Schneider 2017-01-21 22:36:43 +01:00
commit d3e7942785
19 changed files with 199 additions and 67 deletions

View file

@ -2,12 +2,14 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Newtonsoft.Json;
using Yavsc.Models.Access;
using YavscLib;
namespace Yavsc.Models
{
public partial class Blog : IBlog
public partial class Blog : IBlog, ICircleAuthorized
{
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public long Id { get; set; }
@ -42,7 +44,22 @@ namespace Yavsc.Models
get; set;
}
[InverseProperty("Post")]
[InverseProperty("Target")]
public virtual List<CircleAuthorizationToBlogPost> ACL { get; set; }
public bool AuthorizeCircle(long circleId)
{
return ACL.Any( i=>i.CircleId == circleId);
}
public string GetOwnerId()
{
return AuthorId;
}
public ICircleAuthorization[] GetACL()
{
return ACL.ToArray();
}
}
}

View file

@ -1,15 +0,0 @@
using System.ComponentModel.DataAnnotations.Schema;
namespace Yavsc.Models
{
public partial class BlogAccess
{
[ForeignKey("Blog.Id")]
public long PostId { get; set; }
[ForeignKey("Circle.Id")]
public long CircleId { get; set; }
}
}