// PUT: api/TopSpots/5 public void Put(spotIndex index, [FromBody] TopSpot topSpot) { var list = JsonConvert.DeserializeObject <List <TopSpot> >(File.ReadAllText("C:/dev/TopSpotsAPI/topspots.json")); list[index.index].Name = topSpot.Name; list[index.index].Description = topSpot.Description; list[index.index].Location[0] = topSpot.Location[0]; list[index.index].Location[1] = topSpot.Location[1]; var convertedJson = JsonConvert.SerializeObject(list, Formatting.Indented); Console.Write(convertedJson); File.WriteAllText("C:/dev/TopSpotsAPI/topspots.json", convertedJson); }
// DELETE: api/TopSpots/5 public HttpResponseMessage Delete([FromBody] spotIndex index) { var list = JsonConvert.DeserializeObject <List <TopSpot> >(File.ReadAllText("C:/dev/TopSpotsAPI/topspots.json")); list.RemoveAt(index.index); var convertedJson = JsonConvert.SerializeObject(list, Formatting.Indented); Console.Write(convertedJson); File.WriteAllText("C:/dev/TopSpotsAPI/topspots.json", convertedJson); return(Request.CreateResponse(HttpStatusCode.OK, new { index = index })); }