| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- 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<string> 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)
- {
- }
- }
- }
|