perf pro api
This commit is contained in:
parent
a6fe73c7f6
commit
f16841f8d7
6 changed files with 52 additions and 13 deletions
|
|
@ -6,6 +6,7 @@ using Yavsc.Models;
|
||||||
using Yavsc.Models.Workflow;
|
using Yavsc.Models.Workflow;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using Microsoft.AspNet.Authorization;
|
using Microsoft.AspNet.Authorization;
|
||||||
|
using Microsoft.Data.Entity;
|
||||||
|
|
||||||
namespace Yavsc.Controllers
|
namespace Yavsc.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -24,15 +25,32 @@ namespace Yavsc.Controllers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[Authorize(Roles="Performer")]
|
[Authorize(Roles="Performer"),HttpGet("{id}")]
|
||||||
public IActionResult Get(string 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)
|
if (id==null)
|
||||||
{
|
{
|
||||||
ModelState.AddModelError("id","Specifier un code activité");
|
ModelState.AddModelError("id","Specifier un identifiant de prestataire valide");
|
||||||
return new BadRequestObjectResult(ModelState);
|
|
||||||
}
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -11,6 +11,8 @@ namespace Yavsc.Models
|
||||||
using Models.Chat;
|
using Models.Chat;
|
||||||
using Models.Bank;
|
using Models.Bank;
|
||||||
using Models.Access;
|
using Models.Access;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
public class ApplicationUser : IdentityUser
|
public class ApplicationUser : IdentityUser
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -40,24 +42,24 @@ namespace Yavsc.Models
|
||||||
/// User's posts
|
/// User's posts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[InverseProperty("Author")]
|
[InverseProperty("Author"),JsonIgnore]
|
||||||
public virtual List<Blog> Posts { get; set; }
|
public virtual List<Blog> Posts { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// User's contact list
|
/// User's contact list
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[InverseProperty("Owner")]
|
[InverseProperty("Owner"),JsonIgnore]
|
||||||
public virtual List<Contact> Book { get; set; }
|
public virtual List<Contact> Book { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// External devices using the API
|
/// External devices using the API
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[InverseProperty("DeviceOwner")]
|
[InverseProperty("DeviceOwner"),JsonIgnore]
|
||||||
public virtual List<GoogleCloudMobileDeclaration> Devices { get; set; }
|
public virtual List<GoogleCloudMobileDeclaration> Devices { get; set; }
|
||||||
|
|
||||||
[InverseProperty("Owner")]
|
[InverseProperty("Owner"),JsonIgnore]
|
||||||
public virtual List<Connection> Connections { get; set; }
|
public virtual List<Connection> Connections { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -65,7 +67,7 @@ namespace Yavsc.Models
|
||||||
/// User's circles
|
/// User's circles
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[InverseProperty("Owner")]
|
[InverseProperty("Owner"),JsonIgnore]
|
||||||
|
|
||||||
public virtual List<Circle> Circles { get; set; }
|
public virtual List<Circle> Circles { get; set; }
|
||||||
|
|
||||||
|
|
@ -90,6 +92,7 @@ namespace Yavsc.Models
|
||||||
public long DiskQuota { get; set; } = 512*1024*1024;
|
public long DiskQuota { get; set; } = 512*1024*1024;
|
||||||
public long DiskUsage { get; set; } = 0;
|
public long DiskUsage { get; set; } = 0;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
public virtual List<BlackListed> BlackList { get; set; }
|
public virtual List<BlackListed> BlackList { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,9 @@ using System.ComponentModel.DataAnnotations.Schema;
|
||||||
namespace Yavsc.Models.Workflow
|
namespace Yavsc.Models.Workflow
|
||||||
{
|
{
|
||||||
using Models.Relationship;
|
using Models.Relationship;
|
||||||
|
using YavscLib.Workflow;
|
||||||
public class PerformerProfile {
|
|
||||||
|
public class PerformerProfile : IPerformerProfile {
|
||||||
|
|
||||||
[Key]
|
[Key]
|
||||||
public string PerformerId { get; set; }
|
public string PerformerId { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
<div class="carousel-caption-s" >
|
<div class="carousel-caption-s" >
|
||||||
|
|
||||||
@if (act.Children.Count>0) {
|
@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>
|
@act.Description </p>
|
||||||
<a asp-route-id="@act.Code">
|
<a asp-route-id="@act.Code">
|
||||||
@foreach (Activity c in act.Children) {
|
@foreach (Activity c in act.Children) {
|
||||||
|
|
|
||||||
2
Yavsc/wwwroot/css/site.min.css
vendored
2
Yavsc/wwwroot/css/site.min.css
vendored
File diff suppressed because one or more lines are too long
17
YavscLib/Workflow/IPerformerProfile.cs
Normal file
17
YavscLib/Workflow/IPerformerProfile.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue