I am using Web Api with ASP.NET MVC, and I am very new to it. I have gone through some demo on asp.net website and I am trying to do the following.
I have 4 get methods, with the following signatures
public List<Customer> Get()
{
// gets all customer
}
public List<Customer> GetCustomerByCurrentMonth()
{
// gets some customer on some logic
}
public Customer GetCustomerById(string id)
{
// gets a single customer using id
}
public Customer GetCustomerByUsername(string username)
{
// gets a single customer using username
}
For all the methods above I would like to have my web api somewhat like as shown below
- List Get() =
api/customers/
- Customer GetCustomerById(string Id) =
api/customers/13
- List GetCustomerByCurrentMonth() =
/customers/currentMonth
- Customer GetCustomerByUsername(string username) =
/customers/customerByUsername/yasser
I tried making changes to routing, but as I am new to it, could'nt understand much.
So, please can some one help me understand and guide me on how this should be done. Thanks