Link to home
Start Free TrialLog in
Avatar of ITsolutionWizard
ITsolutionWizardFlag for United States of America

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?
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ITsolutionWizard

ASKER

hmmm...not all. We can create test webapi project, but we are really green on this. Hope to get more information to start.

Thanks
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();
        }
         


    }
}

Open in new window

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.
i am beginner and please use my codes to start with.
Then you should ask for Live/Gig.