public ActionResult Create(CategoriaRecomendacion categoriarecomendacion) { if (ModelState.IsValid) { db.CategoriaRecomendacion.Add(categoriarecomendacion); db.SaveChanges(); return RedirectToAction("Index"); } return View(categoriarecomendacion); }
// POST api/CategoriaRecomendacion public HttpResponseMessage PostCategoriaRecomendacion(CategoriaRecomendacion categoriarecomendacion) { if (ModelState.IsValid) { db.CategoriaRecomendacion.Add(categoriarecomendacion); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, categoriarecomendacion); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = categoriarecomendacion.idCategoria })); return response; } else { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }
// PUT api/CategoriaRecomendacion/5 public HttpResponseMessage PutCategoriaRecomendacion(int id, CategoriaRecomendacion categoriarecomendacion) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } if (id != categoriarecomendacion.idCategoria) { return Request.CreateResponse(HttpStatusCode.BadRequest); } db.Entry(categoriarecomendacion).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex); } return Request.CreateResponse(HttpStatusCode.OK); }
public ActionResult Edit(CategoriaRecomendacion categoriarecomendacion) { if (ModelState.IsValid) { db.Entry(categoriarecomendacion).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(categoriarecomendacion); }