ASP.NET MVC 4 Web API v2 – Attribute Routing

ASP.NET MVC 4 Web API v2 – Attribute Routing

   Web API Controller
 
   using System;
   using System.Collections.Generic;
   using System.Web.Http;
   using SoccerWebAPIRest.Models;
   using Oracle.DataAccess;
   using Oracle.DataAccess.Client;
 
   namespace SoccerWebAPIRest.Controllers
   {
      public class PlayerController : ApiController
      {
 
         [Route("rest/player")]
         public List<PlayerView> GetAllPlayer()
         {
            … …
         }
 
         [Route("rest/player/{id}")]
         public PlayerView GetSinglePlayer(int? id)
         {
            … …
         }
 
         [Route("rest/player/team/{id}")]
         public List<PlayerView> GetPlayerByTeam(int? id)
         {
            … …
         }
 
         [Route("rest/player/nation/{id}")]
         public List<PlayerView> GetPlayerByNation(int? id)
         {
            … …
         }
 
      }
   }