yavsc/Yavsc/ApiControllers/PerformersApiController.cs

38 lines
1 KiB
C#
Raw Normal View History

2017-01-31 13:21:42 +01:00
using System.Collections.Generic;
using Microsoft.AspNet.Mvc;
using System.Linq;
using Yavsc.Models;
using Yavsc.Models.Workflow;
2017-02-20 15:53:25 +01:00
using System.Security.Claims;
using Microsoft.AspNet.Authorization;
2017-01-31 13:21:42 +01:00
namespace Yavsc.Controllers
{
[Produces("application/json")]
[Route("api/performers")]
public class PerformersApiController : Controller
{
ApplicationDbContext dbContext;
public PerformersApiController(ApplicationDbContext context)
{
dbContext = context;
}
2017-02-20 15:53:25 +01:00
/// <summary>
/// Lists profiles on an activity code
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[Authorize(Roles="Performer")]
public IActionResult Get(string id)
2017-01-31 13:21:42 +01:00
{
2017-02-20 15:53:25 +01:00
if (id==null)
{
ModelState.AddModelError("id","Specifier un code activité");
return new BadRequestObjectResult(ModelState);
}
return Ok(dbContext.Performers.Where(p=>p.Active && p.PerformerId == id));
2017-01-31 13:21:42 +01:00
}
}
}