using System; using System.Collections.Generic; using System.Linq; using System.Web.Http; using System.IO; namespace ModelePWA.Controllers { public class ModelePWAController : ApiController { // GET: api/modelepwa public IEnumerable Get() { var files = Directory.EnumerateFiles(System.Web.HttpContext.Current.Server.MapPath(@"~/data/")); return files.ToArray(); } // GET: api/modelepwa/5 public string Get(string name) { return File.ReadAllText(System.Web.HttpContext.Current.Server.MapPath(@"~/data/" + name + ".json")); } // POST: api/modelepwa public bool Post([FromBody]string value) { var data = System.Web.HttpContext.Current.Request["data"]; var f= File.CreateText(System.Web.HttpContext.Current.Server.MapPath(@"~/data/" + Guid.NewGuid() +".json")); f.Write(data); f.Close(); return true; } // PUT: api/modelepwa/5 public void Put(int id, [FromBody]string value) { } // DELETE: api/modelepwa/5 public void Delete(int id) { } } }