diff --git a/Yavsc/ApiControllers/PerformersApiController.cs b/Yavsc/ApiControllers/PerformersApiController.cs index bcf353d0..0c2bb0b2 100644 --- a/Yavsc/ApiControllers/PerformersApiController.cs +++ b/Yavsc/ApiControllers/PerformersApiController.cs @@ -6,6 +6,7 @@ using Yavsc.Models; using Yavsc.Models.Workflow; using System.Security.Claims; using Microsoft.AspNet.Authorization; +using Microsoft.Data.Entity; namespace Yavsc.Controllers { @@ -24,15 +25,32 @@ namespace Yavsc.Controllers /// /// /// - [Authorize(Roles="Performer")] + [Authorize(Roles="Performer"),HttpGet("{id}")] public IActionResult Get(string id) { + var pfr = dbContext.Performers.Include( + p=>p.OrganizationAddress + ).Include( + p=>p.Performer + ).Include( + p=>p.Performer.Posts + ).SingleOrDefault(p=> p.PerformerId == id); if (id==null) { - ModelState.AddModelError("id","Specifier un code activité"); - return new BadRequestObjectResult(ModelState); + ModelState.AddModelError("id","Specifier un identifiant de prestataire valide"); } - return Ok(dbContext.Performers.Where(p=>p.Active && p.PerformerId == id)); + else { + var uid = User.GetUserId(); + if (!User.IsInRole("Administrator")) + if (uid != id) return new ChallengeResult(); + + if (!pfr.Active) + { + ModelState.AddModelError("id","Prestataire désactivé."); + } + } + if (ModelState.IsValid) return Ok(pfr); + return new BadRequestObjectResult(ModelState); } } } \ No newline at end of file diff --git a/Yavsc/Models/Identity/ApplicationUser.cs b/Yavsc/Models/Identity/ApplicationUser.cs index 7488326d..f799b452 100644 --- a/Yavsc/Models/Identity/ApplicationUser.cs +++ b/Yavsc/Models/Identity/ApplicationUser.cs @@ -11,6 +11,8 @@ namespace Yavsc.Models using Models.Chat; using Models.Bank; using Models.Access; + using Newtonsoft.Json; + public class ApplicationUser : IdentityUser { /// @@ -40,24 +42,24 @@ namespace Yavsc.Models /// User's posts /// /// - [InverseProperty("Author")] + [InverseProperty("Author"),JsonIgnore] public virtual List Posts { get; set; } /// /// User's contact list /// /// - [InverseProperty("Owner")] + [InverseProperty("Owner"),JsonIgnore] public virtual List Book { get; set; } /// /// External devices using the API /// /// - [InverseProperty("DeviceOwner")] + [InverseProperty("DeviceOwner"),JsonIgnore] public virtual List Devices { get; set; } - [InverseProperty("Owner")] + [InverseProperty("Owner"),JsonIgnore] public virtual List Connections { get; set; } @@ -65,7 +67,7 @@ namespace Yavsc.Models /// User's circles /// /// - [InverseProperty("Owner")] + [InverseProperty("Owner"),JsonIgnore] public virtual List Circles { get; set; } @@ -90,6 +92,7 @@ namespace Yavsc.Models public long DiskQuota { get; set; } = 512*1024*1024; public long DiskUsage { get; set; } = 0; + [JsonIgnore] public virtual List BlackList { get; set; } } } diff --git a/Yavsc/Models/Workflow/PerformerProfile.cs b/Yavsc/Models/Workflow/PerformerProfile.cs index dcbc34ab..b6318e03 100644 --- a/Yavsc/Models/Workflow/PerformerProfile.cs +++ b/Yavsc/Models/Workflow/PerformerProfile.cs @@ -5,8 +5,9 @@ using System.ComponentModel.DataAnnotations.Schema; namespace Yavsc.Models.Workflow { using Models.Relationship; - - public class PerformerProfile { + using YavscLib.Workflow; + + public class PerformerProfile : IPerformerProfile { [Key] public string PerformerId { get; set; } diff --git a/Yavsc/Views/Home/Index.cshtml b/Yavsc/Views/Home/Index.cshtml index 76c2bfa8..47f217ce 100755 --- a/Yavsc/Views/Home/Index.cshtml +++ b/Yavsc/Views/Home/Index.cshtml @@ -27,7 +27,7 @@