Example #1
0
        // 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());
        }
Example #2
0
        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());
        }
Example #3
0
        // 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());
        }
Example #4
0
        // 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());
        }