ITsolutionWizard
asked on
restful api c#
I already have model and controller that basically doing all the work I need. model is basically our domain class.
and controller is just all of combined classes that do all the thing we want like add, modify the data in xml or database.
our next is to create restful API that allow external users to use it. Do you have very simple example for us to get start it?
and controller is just all of combined classes that do all the thing we want like add, modify the data in xml or database.
our next is to create restful API that allow external users to use it. Do you have very simple example for us to get start it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
For example, I have the class codes below. How can I switch to Restful API?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Controller
{
public class State
{
public List<Domain.State> List()
{
Repository.StateDataContext sdc = new Repository.StateDataContext();
return
(
from stateData in sdc.States
select new Domain.State()
{
fullName = stateData.FullName,
abbr = stateData.Abbr
}
).ToList();
}
public List<Domain.State> List(string keywords)
{
Repository.StateDataContext sdc = new Repository.StateDataContext();
return
(
from stateData in sdc.States
where stateData.FullName.StartsWith(keywords)
select new Domain.State()
{
fullName = stateData.FullName,
abbr = stateData.Abbr
}
).ToList();
}
}
}
ASKER
any one can help?
In this case: Learn About ASP.NET Web API.
Just create a new WebAPI project in your solution (Getting Started with ASP.NET Web API 2 (C#)). An just wrap your controllers methods in the WebAPI controller.
This is not as much work and not that complex. Just take a look at the samples and videos on ASP.NET. You can get a working WebAPI pretty quickly.
Just create a new WebAPI project in your solution (Getting Started with ASP.NET Web API 2 (C#)). An just wrap your controllers methods in the WebAPI controller.
This is not as much work and not that complex. Just take a look at the samples and videos on ASP.NET. You can get a working WebAPI pretty quickly.
ASKER
i am beginner and please use my codes to start with.
Then you should ask for Live/Gig.
ASKER
Thanks