perf pro api

This commit is contained in:
2017-02-21 20:49:07 +01:00
parent d26f100b43
commit 073d32fa62
6 changed files with 52 additions and 13 deletions

View File

@ -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
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[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);
}
}
}

View File

@ -11,6 +11,8 @@ namespace Yavsc.Models
using Models.Chat;
using Models.Bank;
using Models.Access;
using Newtonsoft.Json;
public class ApplicationUser : IdentityUser
{
/// <summary>
@ -40,24 +42,24 @@ namespace Yavsc.Models
/// User's posts
/// </summary>
/// <returns></returns>
[InverseProperty("Author")]
[InverseProperty("Author"),JsonIgnore]
public virtual List<Blog> Posts { get; set; }
/// <summary>
/// User's contact list
/// </summary>
/// <returns></returns>
[InverseProperty("Owner")]
[InverseProperty("Owner"),JsonIgnore]
public virtual List<Contact> Book { get; set; }
/// <summary>
/// External devices using the API
/// </summary>
/// <returns></returns>
[InverseProperty("DeviceOwner")]
[InverseProperty("DeviceOwner"),JsonIgnore]
public virtual List<GoogleCloudMobileDeclaration> Devices { get; set; }
[InverseProperty("Owner")]
[InverseProperty("Owner"),JsonIgnore]
public virtual List<Connection> Connections { get; set; }
@ -65,7 +67,7 @@ namespace Yavsc.Models
/// User's circles
/// </summary>
/// <returns></returns>
[InverseProperty("Owner")]
[InverseProperty("Owner"),JsonIgnore]
public virtual List<Circle> 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<BlackListed> BlackList { get; set; }
}
}

View File

@ -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; }

View File

@ -27,7 +27,7 @@
<div class="carousel-caption-s" >
@if (act.Children.Count>0) {
<p><em><a asp-route-id="@act.Code">@act.Name</a></em><br/>
<p><em>@act.Name</em><br/>
@act.Description </p>
<a asp-route-id="@act.Code">
@foreach (Activity c in act.Children) {

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,17 @@
namespace YavscLib.Workflow
{
public interface IPerformerProfile
{
string PerformerId { get; set; }
string SIREN { get; set; }
bool AcceptNotifications { get; set; }
long OrganizationAddressId { get; set; }
bool AcceptPublicContact { get; set; }
bool UseGeoLocalizationToReduceDistanceWithClients { get; set; }
string WebSite { get; set; }
bool Active { get; set; }
int? MaxDailyCost { get; set; }
int? MinDailyCost { get; set; }
int Rate { get; set; }
}
}