예제 #1
0
 public IEnumerable <Club> Get()
 {
     using (coachEntities entities = new coachEntities())
     {
         return(entities.Clubs.ToList());
     }
 }
예제 #2
0
 public IEnumerable <User> Get()
 {
     using (coachEntities entities = new coachEntities())
     {
         return(entities.Users.ToList());
     }
 }
예제 #3
0
        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);
        }
예제 #4
0
        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));
        }