yavsc/Yavsc/ApiControllers/PerformersApiController.cs

38 lines
1.0 KiB
C#

8 years ago
using System.Collections.Generic;
using Microsoft.AspNet.Mvc;
using System.Linq;
using Yavsc.Models;
using Yavsc.Models.Workflow;
8 years ago
using System.Security.Claims;
using Microsoft.AspNet.Authorization;
8 years ago
namespace Yavsc.Controllers
{
[Produces("application/json")]
[Route("api/performers")]
public class PerformersApiController : Controller
{
ApplicationDbContext dbContext;
public PerformersApiController(ApplicationDbContext context)
{
dbContext = context;
}
8 years ago
/// <summary>
/// Lists profiles on an activity code
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[Authorize(Roles="Performer")]
public IActionResult Get(string id)
8 years ago
{
8 years ago
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));
8 years ago
}
}
}