none
Asp net core api problème accès à une méthode de l'api RRS feed

  • Question

  • bonjour,

    je débute avec les api et j'ai un comportement bizarre.

    Quand je déploie mon api sur azure je n'arrive pas à acceder à une methode(erreur 404) de mon controller alors que j'arrive a joindre d'autres méthodes du meme controller.

    Pourtant quand j’exécute l'api en local(localhost) , j'arrive à accéder à cette méthode.

    Auriez-vous une idée ? c'est la méthode : AllPeriod

    Merci d'avance


    [Route("api/[controller]")]
    [ApiController]
    [EnableCors("SiteCorsPolicy")]
    public class PaymentController : ControllerBase
    {
    private readonly GestAssoContext _context;
    private string currentMonth;
    public PaymentController(GestAssoContext context)
    {
    _context = context;
    currentMonth = DateTime.Today.ToString("MM-yyyy");
    }
    [HttpGet]
    public ActionResult<List<Payment>> GetAll()
    {
    return _context.Payment
    .Include(p => p.PaymentDetails).ThenInclude(pd => pd.PaymentType)
    .Include(p => p.Member).ThenInclude(m => m.MemberSettings).ThenInclude(pd => pd.PaymentType)
    .Include(p => p.MemberContributor)
    .Include(p => p.Validator)
    .ToList();
    }
    [HttpGet]
    [Route("[action]/{month}")]
    public ActionResult<List<Payment>> AllByPeriod(string month)
    {
    return _context.Payment
    .Where(p => p.Month == month)
    .Include(p => p.PaymentDetails).ThenInclude(pd => pd.PaymentType)
    .Include(p => p.Member).ThenInclude(m => m.MemberSettings).ThenInclude(pd => pd.PaymentType)
    .Include(p => p.MemberContributor)
    .Include(p => p.Validator)
    .ToList();
    }
    [Authorize(Roles = "SuperUser,Manager,Supervision")]
    [HttpGet]
    [Route("[action]")]
    public ActionResult<List<Payment>> getAllPaymentsToValidate()
    {
    return _context.Payment
    .Where(p => !p.Validated)
    .Include(p => p.PaymentDetails).ThenInclude(pd => pd.PaymentType)
    .Include(p => p.Member).ThenInclude(m => m.MemberSettings).ThenInclude(pd => pd.PaymentType)
    .Include(p => p.MemberContributor)
    .Include(p => p.Validator)
    .ToList();
    }
    [HttpGet]
    [Route("[action]/{id}")]
    public ActionResult<Payment> GetById(Guid id)
    {
    var item = _context.Payment.Find(id);
    if (item == null)
    return NotFound();
    return item;
    }
    [HttpGet]
    [Route("[action]/{id}")]
    public ActionResult<List<Payment>> GetAllByMemberId(Guid id)
    {
    var item = _context.Payment
    .Include(p => p.PaymentDetails)
    .Include(p => p.Member)
    .ThenInclude(m => m.MemberSettings).ThenInclude(pd => pd.PaymentType)
    .Where(p => p.Member.MemberId == id)
    .ToList();
    if (item == null)
    return NotFound();
    return item;
    }
    mercredi 20 mars 2019 16:57

Réponses

Toutes les réponses