// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Collections.Generic; using System.Web.Http; using WS; namespace WS.WebApi { public class RepoServiceController : ApiController { private static DataService ds = new DataService(); // Web API does not support singleton mode [HttpGet] public IEnumerable GetAllData() { lock(ds) { return ds.GetAll(); } } [HttpGet] public Data GetDataById(int id) { lock(ds) { return ds.GetOne(id); } } [HttpPost] public void PostData(Data o) { lock(ds) { ds.Add(o); } } } }