public IHttpActionResult PutPelicula(int id, Pelicula pelicula) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != pelicula.id) { return BadRequest(); } db.Entry(pelicula).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PeliculaExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public ActionResult Create(Pelicula pelicula) { if (ModelState.IsValid) { db.Peliculas.Add(pelicula); db.SaveChanges(); return RedirectToAction("Index"); } return View(pelicula); }
public IHttpActionResult PostPelicula(Pelicula pelicula) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Peliculas.Add(pelicula); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = pelicula.id }, pelicula); }
public ActionResult Edit(Pelicula pelicula, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); var path = Path.Combine(Server.MapPath("~/Content/imagenes"), fileName); file.SaveAs(path); path = "/content/imagenes/" + fileName; pelicula.Ruta = path; } db.Entry(pelicula).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(pelicula); }
public ActionResult Edit(Pelicula pelicula) { if (ModelState.IsValid) { db.Entry(pelicula).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(pelicula); }