Ejemplo n.º 1
0
 public void PutClass(int id, Class clss)
 {
     clss.Id = id;
     dbCtxt.Classes.Attach(clss);
     dbCtxt.Entry(clss).State = System.Data.EntityState.Modified;
     dbCtxt.SaveChanges();
 }
Ejemplo n.º 2
0
        public HttpResponseMessage PostClass(Class clss)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, this.ModelState));
            }

            dbCtxt.Classes.Add(clss);
            int records = dbCtxt.SaveChanges();

            var response = Request.CreateResponse(HttpStatusCode.Created, clss);
            response.Headers.Location = new Uri(Url.Link(ODataRouteNames.GetById, new { Controller = "Classes", Id = clss.Id }));
            return response;
        }