// POST api/profesorfavoritoes public HttpResponseMessage Postprofesorfavorito(profesorfavorito profesorfavorito) { if (ModelState.IsValid) { db.profesorfavoritoes.Add(profesorfavorito); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, profesorfavorito); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = profesorfavorito.id })); return(response); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }
// DELETE api/profesorfavoritoes/5 public HttpResponseMessage Deleteprofesorfavorito(int id) { profesorfavorito profesorfavorito = db.profesorfavoritoes.Find(id); if (profesorfavorito == null) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } db.profesorfavoritoes.Remove(profesorfavorito); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK, profesorfavorito)); }
// PUT api/profesorfavoritoes/5 public HttpResponseMessage Putprofesorfavorito(int id, profesorfavorito profesorfavorito) { if (ModelState.IsValid && id == profesorfavorito.id) { db.Entry(profesorfavorito).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } }