public IEnumerable <Club> Get() { using (coachEntities entities = new coachEntities()) { return(entities.Clubs.ToList()); } }
public IEnumerable <User> Get() { using (coachEntities entities = new coachEntities()) { return(entities.Users.ToList()); } }
public HttpResponseMessage Get(int id) { coachEntities db = new coachEntities(); var data = from i in db.Clubs where i.ID == id select i; Club img = (Club)data.SingleOrDefault(); byte[] imgData = img.img; MemoryStream ms = new MemoryStream(imgData); HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); response.Content = new StreamContent(ms); response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("image/png"); return(response); }
public IHttpActionResult Post(User tb) { coachEntities db = new coachEntities(); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Users.Add(tb); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tb.ID }, tb)); }