public HttpResponseMessage PostP_Notas(P_Notas p_notas) { if (ModelState.IsValid) { db.P_Notas.Add(p_notas); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, p_notas); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = p_notas.IdPersona })); return response; } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }
public HttpResponseMessage PutP_Notas(int id, P_Notas p_notas) { if (ModelState.IsValid && id == p_notas.IdPersona) { db.Entry(p_notas).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { return Request.CreateResponse(HttpStatusCode.NotFound); } return Request.CreateResponse(HttpStatusCode.OK); } else { return Request.CreateResponse(HttpStatusCode.BadRequest); } }