// GET api/values public IEnumerable <string> Get() { annshopDBEntities db = new annshopDBEntities(); List <TestTable> table = db.TestTable.ToList(); List <string> ret = new List <string>(); foreach (TestTable t in table) { ret.Add(t.value); } return(ret.ToArray()); }
public ActionResult About() { annshopDBEntities db = new annshopDBEntities(); List <TestTable> table = db.TestTable.ToList(); string response = ""; foreach (TestTable t in table) { response += " - " + t.value + "\n"; } ViewBag.Message = "TestTable Values: \n" + response; return(View()); }
// POST api/values public IHttpActionResult Post(TestValue value) { if (!ModelState.IsValid) { return(BadRequest("Invalid data.")); } annshopDBEntities db = new annshopDBEntities(); TestTable tt = new TestTable(); tt.value = value.value; db.TestTable.Add(tt); db.SaveChanges(); return(Ok()); }
// GET api/values/5 public string Get(int id) { annshopDBEntities db = new annshopDBEntities(); return(db.TestTable.Where(t => t.id == id).Select(t => t.value).FirstOrDefault()); }