public ActionResult Calcular(Prenda prenda) { Tipo tipoPrenda = db.Tipoes.Where(x => x.Id == prenda.TipoId).FirstOrDefault(); var manoobra = tipoPrenda.Precio; var preciotela = 0; var precioavio = 0; var precioprenda = 0; foreach (var item in prenda.DetallePrendas) { Tela tela = db.Telas.Find(item.TelaId); Avio avio = db.Avios.Find(item.AvioId); if (tela != null) { preciotela += tela.Precio * (int)item.MetroTela; item.Tela = tela; } if (avio != null) { precioavio += avio.Precio * item.CantidadAvio; item.Avio = avio; } } precioprenda = manoobra + preciotela + precioavio; prenda.PrecioTotal = precioprenda; ViewBag.TipoId = new SelectList(db.Tipoes, "Id", "Categoria"); 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 precioprenda; return(View(prenda)); }
public ActionResult DeleteConfirmed(int id) { Avio avio = db.Avios.Find(id); db.Avios.Remove(avio); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Nombre,Precio")] Avio avio) { if (ModelState.IsValid) { db.Entry(avio).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(avio)); }
public ActionResult Create([Bind(Include = "Id,Nombre,Precio")] Avio avio) { if (ModelState.IsValid) { db.Avios.Add(avio); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(avio)); }
// GET: Avios/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Avio avio = db.Avios.Find(id); if (avio == null) { return(HttpNotFound()); } return(View(avio)); }