public ActionResult Edit(Prenda prenda) { if (ModelState.IsValid) { db.Entry(prenda).State = EntityState.Modified; db.SaveChanges(); using (var contexto = new ApplicationDbContext()) { foreach (var item in prenda.DetallePrendas) { var detalles = new DetallePrenda() { Id = item.Id, AvioId = item.AvioId, CantidadAvio = item.CantidadAvio, MetroTela = item.MetroTela, PrendaId = item.PrendaId, TelaId = item.TelaId }; contexto.DetallePrendas.Add(detalles); contexto.Entry(detalles).State = EntityState.Modified; contexto.SaveChanges(); } } return(RedirectToAction("Index")); } ViewBag.TipoId = new SelectList(db.Tipoes, "Id", "Categoria", prenda.TipoId); ViewBag.UserId = new SelectList(db.Users, "Id", "Nombre", prenda.UserId); ViewBag.AvioId = new SelectList(db.Avios, "Id", "Nombre"); ViewBag.PrendaId = new SelectList(db.Prendas, "Id", "UserId"); ViewBag.TelaId = new SelectList(db.Telas, "Id", "Nombre"); return(View(prenda)); }
public ActionResult DeleteConfirmed(int id) { DetallePrenda detallePrenda = db.DetallePrendas.Find(id); db.DetallePrendas.Remove(detallePrenda); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,PrendaId,AvioId,TelaId,MetroTela,CantidadAvio")] DetallePrenda detallePrenda) { if (ModelState.IsValid) { db.Entry(detallePrenda).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AvioId = new SelectList(db.Avios, "Id", "Nombre", detallePrenda.AvioId); ViewBag.PrendaId = new SelectList(db.Prendas, "Id", "UserId", detallePrenda.PrendaId); ViewBag.TelaId = new SelectList(db.Telas, "Id", "Nombre", detallePrenda.TelaId); return(View(detallePrenda)); }
// GET: DetallePrendas/Create public ActionResult Create(int TelaId) { DetallePrenda detalle = new DetallePrenda(); Tela t = db.Telas.Find(TelaId); detalle.Tela = t; detalle.TelaId = t.Id; detalle.TelaId = TelaId; ViewBag.AvioId = new SelectList(db.Avios, "Id", "Nombre"); ViewBag.PrendaId = new SelectList(db.Prendas, "Id", "UserId"); ViewBag.TelaId = new SelectList(db.Telas, "Id", "Nombre"); return(View()); }
// GET: DetallePrendas/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DetallePrenda detallePrenda = db.DetallePrendas.Find(id); if (detallePrenda == null) { return(HttpNotFound()); } return(View(detallePrenda)); }
// GET: DetallePrendas/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DetallePrenda detallePrenda = db.DetallePrendas.Find(id); if (detallePrenda == null) { return(HttpNotFound()); } ViewBag.AvioId = new SelectList(db.Avios, "Id", "Nombre", detallePrenda.AvioId); ViewBag.PrendaId = new SelectList(db.Prendas, "Id", "UserId", detallePrenda.PrendaId); ViewBag.TelaId = new SelectList(db.Telas, "Id", "Nombre", detallePrenda.TelaId); return(View(detallePrenda)); }