ITsolutionWizard
asked on
MVC API
I have the codes below inside of the Controllers in MVC project. This is API project that I tried to learn.
My question is: how can I create end point for Get(int id)? Should I create a VIEW?
My goal is to create end point, and I will have another website project to call the end point so the website can consume the API service.
My question is: how can I create end point for Get(int id)? Should I create a VIEW?
My goal is to create end point, and I will have another website project to call the end point so the website can consume the API service.
public class LeadController : Controller
{
[HttpGet]
public IEnumerable<CrmModels.Lead> Get(int id)
{
CrmModels.Lead l = new CrmModels.Lead();
List<CrmModels.Lead> li = new List<CrmModels.Lead>();
if (id == 1)
{
l.firstName = "John";
li.Add(l);
}
else
{
l.firstName = string.Empty;
li.Add(l);
}
return li;
}
//Get api/lead details
[HttpGet]
public IEnumerable<string> Get()
{
//call crm controllers
return new string[] { "", "" };
}
//create
[HttpPost]
public void Post(CrmModels.Lead l)
{
//call crm controllers
}
//update
[HttpPut]
public void Put(int id)
{
//call crm controllers
}
//delete
[HttpDelete]
public void Delete(CrmModels.Lead l)
{
//call crm controllers
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER